tags:

views:

281

answers:

1
>>> import math
>>> math.sin(68)
-0.897927680689

sin(68)=0.927(3dp)

Any ideas about why I am getting this result? Thanks.

+16  A: 
>>> import math
>>> print math.sin.__doc__
sin(x)

Return the sine of x (measured in radians).

math.sin expects its argument to be in radians, not degrees, so:

>>> import math
>>> print math.sin(math.radians(68))
0.927183854567
mhawke
The docstring is poorly written. It says: "Returns the sign of x, the return value is measured in radians.".
too much php
@too much php: that's a matter of interpretation. The return value is a ratio, not a measurement in any particular unit, so "(measured in radians)" clearly refers to x - the argument.
mhawke
`@too much php`: No it doesn't. It says: `'sin(x)\n\nReturn the sine of x (measured in radians).'` sine(angle) produces number (not angle) ranging from -1 to 1. All angles in everybody's trig library are measured in radians. Your interpretation is unjustifiable.
John Machin
just fyi. help(math.sin) also provides the docstring on math.sin.
monkut