why is math.asin(math.sin(10)) ==10 False ?

This is the place for queries that don't fit in any of the other categories.

why is math.asin(math.sin(10)) ==10 False ?

Postby augre » Thu Apr 04, 2013 12:50 am

Code: Select all
math.asin(math.sin(10)) ==10   
False


why does not the inverse sin give back 10?
Last edited by Yoriz on Thu Apr 04, 2013 5:31 am, edited 1 time in total.
Reason: Added Code tags, altered title a little
augre
 
Posts: 2
Joined: Thu Apr 04, 2013 12:46 am

Re: why is math.asin(math.sin(10)) ==10 False ?

Postby siestamadokaist » Thu Apr 04, 2013 6:02 am

basically, the unit used in sin function is referring to radian instead of degree.

radian has a range of 0 ~ 2pi,
while degree has a range of 0 ~ 360

for example
sin(math.pi) #in radian
is equal to
sin(180) #in degree.

so yeah, you need to convert it first before using it, but since it's python, we're talking about, they might already defined a function to do so.
siestamadokaist
 
Posts: 12
Joined: Sun Mar 31, 2013 4:48 pm

Re: why is math.asin(math.sin(10)) ==10 False ?

Postby setrofim » Thu Apr 04, 2013 6:18 am

siestamadokaist wrote:, but since it's python, we're talking about, they might already defined a function to do so.

http://docs.python.org/2/library/math.html#angular-conversion
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm

Re: why is math.asin(math.sin(10)) ==10 False ?

Postby augre » Thu Apr 04, 2013 11:56 am

Thanks!
Code: Select all
from math import asin, sin, radians, degrees
print degrees(asin(radians(sin(10))))

10
augre
 
Posts: 2
Joined: Thu Apr 04, 2013 12:46 am

Re: why is math.asin(math.sin(10)) ==10 False ?

Postby setrofim » Thu Apr 04, 2013 12:15 pm

Should be
Code: Select all
>>> from math import asin, sin, radians, degrees
>>> print degrees(asin(sin(radians(10))))
10.0

i.e. sin(radians()) not radians(sin())
setrofim
 
Posts: 288
Joined: Mon Mar 04, 2013 7:52 pm


Return to General Coding Help

Who is online

Users browsing this forum: Bing [Bot], Crimson King, Mekire and 11 guests