Python Math asin() Method
Python Math asin() Returns the inverse sine of x in radians.
Python Math asin() Syntax
Here is the syntax of the asin() method:
import math
math.asin(x)
Note: asin() is not directly accessible, you need to import the math module and then call the method via the math static object.
Python Math asin() Parameters
- x : A value between -1 and 1. If x is greater than 1, an error will be generated.
Python Math asin() Return Value
Returns the inverse sine radian of x.
Python Math asin() Example#1
The following shows an example of using the asin() method.
import math
a = math.pi / 8
# returning the value of arc sine of pi / 8
print ("The value of arc sine of pi / 8 is : ", end ="")
print (math.asin(a))
Output:
Python Math asin() Example#2
import math
import matplotlib.pyplot as plt
in_array = [-0.14159265, -0.57039399, -0.28559933, 0.28559933, 0.57039399, 0.94159265]
out_array = []
for i in range(len(in_array)):
out_array.append(math.asin(in_array[i]))
i += 1
print("Input_Array : \n", in_array)
print("\nOutput_Array : \n", out_array)
plt.plot(in_array, out_array, "go:")
plt.title("math.asin() in apidemos.com")
plt.xlabel("X")
plt.ylabel("Y")
plt.show()
Output:
deepinout@ubuntu:~/apidemos.com$ python3 demos.py
Input_Array :
[-0.14159265, -0.57039399, -0.28559933, 0.28559933, 0.57039399, 0.94159265]
Output_Array :
[-0.14207008957392517, -0.6069854488522558, -0.2896317474780172, 0.2896317474780172, 0.6069854488522558, 1.227328875116741]