math module broken?

Dan Bishop danb_83 at yahoo.com
Fri Jul 23 19:55:18 EDT 2004


Helmut Jarausch <jarausch at igpm.rwth-aachen.de> wrote in message news:<4100BE72.1040405 at igpm.rwth-aachen.de>...
...
> If your input is in degrees, define
> 
> def mysin(x)
>      return math.sin(x/pi*180) # 1 degree = 180/pi radians (don's use  x/180*pi)
>
> now
> print mysin(32)  gives 0.529919264233

x/180*pi _is_ correct.  Your formula gives mysin(32) = -0.9408618465702292.

Btw, another way to write this is:

def mysin(x):
   return math.sin(math.radians(x))



More information about the Python-list mailing list