Reference · Math
math.asin
signature
math.asin(num) -> floatWhat it does
The arc sine: the angle in radians, between -pi/2 and pi/2, whose sine is the
number, as Python's math.asin. The number must be between -1 and 1. The angle
in degrees comes from math.degrees.
Examples
print(math.asin(0), math.asin(1), math.asin(-1))print(math.asin(0.5), math.degrees(math.asin(0.5)))output
0.0 1.5707963267948966 -1.57079632679489660.5235987755982989 30.000000000000004Edge cases
- Floating point:
math.asin(0.5)in degrees is29.999999999999996. Round when a clean figure is wanted. - A value a hair past
1from a computation (1.0000000000000002) is a domain error, so clamp a computed value to-1..1first. math.asin(math.sin(x))isxonly forxbetween-pi/2andpi/2.NaNgivesNaN.
print(math.degrees(math.asin(0.5)), round(math.degrees(math.asin(0.5)), 10))let c = 1.0000000000000002print(math.asin(min([1, max([-1, c])])))print(math.asin(math.sin(1)), math.asin(math.sin(3)))print(math.asin(math.nan))output
30.000000000000004 30.01.57079632679489661.0 0.14159265358979323NaNErrors
A number outside -1..1, infinity included, is a runtime error (a domain error), not
an error value: it stops the request, and ?? does not catch it. A value that is not
a number is a runtime error too.
this one fails
print(math.asin(2))output
line 1: `math.asin`: math domain error (2)this one fails
print(math.asin(1.0000000000000002))output
line 1: `math.asin`: math domain error (1.0000000000000002)Chaining
print(0.5 | math.asin | math.degrees | round(6))print([0, 0.5, 1] | map(math.asin))output
30.0[0.0, 0.5235987755982989, 1.5707963267948966]See also
math.sin, math.acos, math.atan, math.atan2, math.degrees
Thread
Thread 0 posts
On math.asin(): questions, tips, corrections, and code that uses it.
No posts yet. The first one opens the thread.
Edit this page on GitHub · every example's output was made by running it (tools/refcheck.mjs) · questions on Discord or r/quillo