GNU bug report logs - #41925
28.0.50; Error using calc-degrees-mode with calc-base-units

Previous Next

Package: emacs;

Reported by: Julien Cubizolles <j.cubizolles <at> free.fr>

Date: Wed, 17 Jun 2020 19:30:02 UTC

Severity: normal

Found in version 28.0.50

To reply to this bug, email your comments to 41925 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-gnu-emacs <at> gnu.org:
bug#41925; Package emacs. (Wed, 17 Jun 2020 19:30:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Julien Cubizolles <j.cubizolles <at> free.fr>:
New bug report received and forwarded. Copy sent to bug-gnu-emacs <at> gnu.org. (Wed, 17 Jun 2020 19:30:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Julien Cubizolles <j.cubizolles <at> free.fr>
To: bug-gnu-emacs <at> gnu.org
Subject: 28.0.50; Error using calc-degrees-mode with calc-base-units
Date: Wed, 17 Jun 2020 21:29:32 +0200
In algebraic mode, with calc-degrees-mode, arctan(ga/(9.8 m/s^2)) gives
0.7857 (close pi/4 radians) instead of 45° as it should. I'm converting
units with calc-base-units, bound to u-b.

Pushing  ga/(9.8 m/s^2), then doing u b and I T gives however 45.

In GNU Emacs 28.0.50 (build 1, x86_64-pc-linux-gnu, GTK+ Version
 3.24.18, cairo version 1.16.0) of 2020-06-14 built on lcy01-amd64-003
 Windowing system distributor 'The X.Org Foundation', version
 11.0.12008000 System Description: Ubuntu 20.04 LTS






Information forwarded to bug-gnu-emacs <at> gnu.org:
bug#41925; Package emacs. (Sat, 20 Jun 2020 16:10:01 GMT) Full text and rfc822 format available.

Message #8 received at 41925 <at> debbugs.gnu.org (full text, mbox):

From: Mattias Engdegård <mattiase <at> acm.org>
To: Julien Cubizolles <j.cubizolles <at> free.fr>
Cc: 41925 <at> debbugs.gnu.org
Subject: bug#41925: 28.0.50; Error using calc-degrees-mode with calc-base-units
Date: Sat, 20 Jun 2020 18:09:27 +0200
It looks like Calc explicitly switches to radians mode during simplification with units:

(defun math-from-radians (a)   ; [N N]
  (cond ((and (not math-simplifying-units)
              (eq calc-angle-mode 'deg))
	 (if (math-constp a)
	     (math-div a (math-pi-over-180))
	   (list 'calcFunc-deg a)))
	((eq calc-angle-mode 'hms)
	 (math-to-hms a 'rad))
	(t a)))

Presumably, this is done because the unit calculations somehow expect everything to be done in radians. I'm not sure how the machinery works, but to hazard a guess, suppose that

 sin(30 deg)

would unit-simplify into

 sin(30*(π/180))

then that would only give the right result if sin(x) only accepted radians no matter the current angle mode during this simplification process.

Obviously I didn't write Calc, and am not sure how to solve it without blowing something else apart. Perhaps you want to give it a go?

It also seems unclear how units and angle mode are supposed to interact. In degrees mode, arctan(1) evaluates to a dimensionless 45, not 45 deg.





This bug report was last modified 3 years and 303 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.