math module broken?
Dan Bishop
danb_83 at yahoo.com
Sat Jul 24 02:00:18 EDT 2004
danb_83 at yahoo.com (Dan Bishop) wrote in message news:<ad052e5c.0407231555.53f3ea11 at posting.google.com>...
> 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))
Even better:
def mysin(x):
return math.sin(math.radians(x % 360))
More information about the Python-list
mailing list