Subject: bug#41925: 28.0.50; Error using calc-degrees-mode with calc-base-units

From: Mattias Engdegård <[email-masked]>
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.