Re: standard trig functions for degrees ?

Henry Baker <[email protected]> Tue, 28 Apr 2026 17:49:58 +0000
Newsgroups gmane.comp.mathematics.maxima.general
Message-ID <[email protected]>
Well, in for a radian, in for a degree !

How about expd(x):=exp(%pi*x/180) and dlog(x):=180*log(x)/%pi
(or logd(x):=180*log(x)/%pi, if you must).

Converting from radians to degrees is thus equivalent to converting from
%e = 2.718... to %E = %e^(%pi/180) = 1.0176...

We'll boil this trig in hot Euler !

-----Original Message-----
From: Stavros Macrakis <[email protected]>
Sent: Apr 28, 2026 8:36 AM
To: <[email protected]>
Cc: <[email protected]>, Robert Dodier <[email protected]>
Subject: Re: [Maxima-discuss] standard trig functions for degrees ?

Just converting back and forth between sin and sind is easy enough.
There are various ways to do it. Probably the cleanest is to use the pattern-matching facility.
You should be able to do it ... and then maybe share it with the community as a share package.
 
But I would strongly oppose adding that to the core system.
 
Maxima is a symbolic system, and functions in the core system should support basic symbolic operations like differentiation, expanding as series, various simplifications, etc., not just numeric evaluation.... (Although I'm sure there are counterexamples where we don't live up to that ideal.)
 
Another problem is that Maxima generally likes to have a quasi-canonical representation for each concept. We don't have both exp(x) and %e^x, for example. It's true that we have both gamma(x) and (x-1)! -- which does add complications. I sometimes wonder why we didn't standardize on one or the other and select the output form with a switch. (Yes, that wouldn't be entirely trivial...).
 
           -s
 
 


On Tue, Apr 28, 2026 at 10:20 AM Henry Baker <[email protected] (mailto:[email protected])> wrote:
Hi Stavros:

You're way ahead of me.

I wasn't thinking of anything like a "units" package, with units like "degrees" or "radians".  While that might be nice, it's far more ambitious than I had in mind.

I was thinking more along the lines of "exponentialize" which converts trig functions into exponentials (and the reverse).



-----Original Message-----
From: Stavros Macrakis <[email protected] (mailto:[email protected])>
Sent: Apr 27, 2026 3:45 PM
To: <[email protected] (mailto:[email protected])>
Cc: <[email protected] (mailto:[email protected])>, Robert Dodier <[email protected] (mailto:[email protected])>
Subject: Re: [Maxima-discuss] standard trig functions for degrees ?

Take a look at the examples I sent before, where that approach doesn't work. For convenience, I'm repeating them below:
 
If you're working in degrees, limit(sind(x)/x,x,0) gives %pi/180; is that what is expected, or does the user want to see (%pi/180)&deg; or maybe 1? Note that sin/cos/etc. don't appear in the result.
 
How do you write the Taylor expansion of sind(x)? The straightforward way gives
 
taylor(sind(x),x,0,3) =>
             (%pi*x)/180-(%pi^3*x^3)/34992000
 
Note that sin/cos/etc. don't appear in the result. Do you write that as something like
 
(x&deg;) -(x&deg;)^3/6
 
How do you know to do that?




On Mon, Apr 27, 2026 at 6:33 PM Henry Baker <[email protected] (mailto:[email protected])> wrote:
No, simply given an expression with "sin" or "asin", rewrite each occurrence with the "sind" or "asind" with the appropriate fudge factor (%pi/180 or 180/%pi) stuck in; ditto in reverse.  Then resimplify, of course.



-----Original Message-----
From: Stavros Macrakis <[email protected] (mailto:[email protected])>
Sent: Apr 27, 2026 3:24 PM
To: <[email protected] (mailto:[email protected])>
Cc: <[email protected] (mailto:[email protected])>, Robert Dodier <[email protected] (mailto:[email protected])>
Subject: Re: [Maxima-discuss] standard trig functions for degrees ?

I'm not sure what you're proposing -- that every function that takes trig functions as input or output will have to be modified?


On Mon, Apr 27, 2026 at 6:20 PM Henry Baker <[email protected] (mailto:[email protected])> wrote:
Well, as ugly as switches are, I suppose one could switch from primitives sind/cosd/tand/asind/acosd/atand to primitives sin/cos/tan/asin/acos/atan or back again with a switch.

I agree that things get ugly when using degrees instead of radians, but some usages of degrees are embedded so tightly into the application context that it seems perverse to insist on radians.

Also, if we are sufficiently knowledgeable about the number %pi/180 -- e.g., identities about its various powers -- some "nice" things may happen that are a bit less obvious when working with radians.



-----Original Message-----
From: Stavros Macrakis <[email protected] (mailto:[email protected])>
Sent: Apr 27, 2026 3:09 PM
To: Henry Baker <[email protected] (mailto:[email protected])>
Cc: <[email protected] (mailto:[email protected])>, Robert Dodier <[email protected] (mailto:[email protected])>
Subject: Re: [Maxima-discuss] standard trig functions for degrees ?

Henry,
 
I really don't know much about working in degrees. Like Ray, the last time I did that was in high school.
 
If you're working in degrees, how do you write, say, the Taylor expansion of sind(x)? The straightforward way gives
 
taylor(sind(x),x,0,3) =>
             (%pi*x)/180-(%pi^3*x^3)/34992000
 
Do you write that as something like
 
(x&deg;) -(x&deg;)^3/6
?


On Mon, Apr 27, 2026 at 5:15 PM Stavros Macrakis <[email protected] (mailto:[email protected])> wrote:
I don't know what exactly Henry wants. If it's just numeric computation, that's trivial. As he says, it's < 1k of code, which he can write himself.
 
The hard part is symbolic computation.

I'd think that someone working in degrees would like to see things like:
 
sind(x/2),halfangles => sqrt(1-cosd(x))/sqrt(2) (for 0<x<360)
 
This gets messier. Yes, you can write pattern matching rules that change all instances of cos(...) to cosd(...), etc.
 
But what about, say, limit(sind(x)/x,x,0)? That gives %pi/180; is that what is expected, or does the user want to see (%pi/180)&deg; or maybe 1? I've never worked in degrees beyond elementary trig, so I don't know what the user expects, and whether the system (as opposed to the user) needs to keep track of degrees vs. radians.
 
Or am I overthinking it?
 
          -s


On Mon, Apr 27, 2026 at 4:45 PM Robert Dodier <[email protected] (mailto:[email protected])> wrote:
On Mon, Apr 27, 2026 at 12:48 PM Henry Baker <[email protected] (mailto:[email protected])> wrote:

> A number of computer languages -- e.g., Fortran -- support trig functions over degrees -- e.g., sind(x), cosd(x), tand(x), asind(x), etc.
>
> I know it's "trivial", but could Maxima please go ahead a define standardly the trig functions over degrees?  We're talking about about increasing the core system at most by perhaps 1K bytes !

Well, maybe the code is trivial, but the increased mental burden is
not ... Instead of creating new functions, I am OK with two functions,
radians(x) to get radians from degrees and degrees(x) to get degrees
from radians. Then one can call those whenever it makes sense.

We could make those simplifying functions. Just thinking out loud here.

Hmm, maybe degrees(x) should represent x degrees, like radians(x)
represents x radians. radians(x) simplifies to x and degrees(x)
simplifies to x*%pi/180. E.g. sin(degrees(90)) --> sin(%pi/2), etc.

I think I'm leaning towards degrees(x) representing x degrees. What
does anyone else think?

Robert


_______________________________________________
Maxima-discuss mailing list
[email protected] (mailto:[email protected])
https://lists.sourceforge.net/lists/listinfo/maxima-discuss

_______________________________________________
Maxima-discuss mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/maxima-discuss