Skip to content Skip to sidebar Skip to footer

Wrong Asin Result

My code: import math x = input() print(math.asin(math.radians(float(x)))) My x was 0.7071067811865475, and the result was some irracional number between 0 and 1, but in my knowled

Solution 1:

You're converting the wrong number with the wrong function.

>>>import math>>>x = 0.7071067811865475>>>math.degrees(math.asin(x))
44.99999999999999
>>>

That is, given x (which is the sine of an angle) call asin to compute the angle (in radians), and then use degrees to convert that angle to degrees.

Solution 2:

math.radians converts to radians, you want math.degrees.

It's also in the wrong place, you're converting a number, not an angle. You want

print(math.degrees(math.asin(float(x))))

https://docs.python.org/3/library/math.html#angular-conversion

Post a Comment for "Wrong Asin Result"