[Python-ideas] Trigonometry in degrees

Steven D'Aprano steve at pearwood.info
Fri Jun 8 08:25:13 EDT 2018

On Fri, Jun 08, 2018 at 06:34:25PM +1200, Greg Ewing wrote:

> I'm not sure what all the fuss is about:
> >>> from math import pi, sin
> >>> sin(pi/2)
> 1.0

Try cos(pi/2) or sin(pi/6).

Or try:

sin(pi/4) == sqrt(2)/2
tan(pi/4) == 1
tan(pi/3) == sqrt(3)

And even tan(pi/2), which ought to be an error, but isn't.

These are, of course, limitations due to the finite precision of floats.

But Julia gets the equivalent degree-based calculations all correct, 
except for tan(90) where it returns Inf (NAN would be better, as the 
limit from below and the limit from above are different).


More information about the Python-ideas mailing list