[Python-ideas] Trigonometry in degrees

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Jun 8 02:34:25 EDT 2018


Stephen J. Turnbull wrote:
> Since Pi is irrational, Pi/4 is too, so it
> definitely cannot be represented.  Making a correction to a number
> that "looks like" Pi/4 is against this philosophy.

I'm not sure what all the fuss is about:

 >>> from math import pi, sin
 >>> sin(pi/2)
1.0
 >>> sin(pi/2 + 2 * pi)
1.0
 >>> sin(pi/2 + 4 * pi)
1.0
 >>> sin(pi/2 + 8 * pi)
1.0
 >>> sin(pi/2 + 16 * pi)
1.0
 >>> sin(pi/2 + 32 * pi)
1.0

Seems to be more than good enough for most angle ranges
that your average schoolkid is going to be plugging
into it.

In fact you have to go quite a long way before expectations
start to break down:

 >>> sin(pi/2 + 10000000 * pi)
1.0
 >>> sin(pi/2 + 100000000 * pi)
0.9999999999999984

-- 
Greg


More information about the Python-ideas mailing list