acos()
acos(x) returns arc cosine of x , the input number x is in radian.
import math
print(math.acos(1)) # 0.0
print(math.acos(0.56)) # 0.9764105267938343
print(math.acos(-0.56)) # 2.165182126795959
print(math.acos(-1)) # 3.141592653589793
print(math.acos(0)) # 1.5707963267948966
Note that all the inputs are in radian.
For any value more than 1 or less than -1 , we will get ValueError
print(math.acos(1.01))
print(math.acos(-1.01))
Above code will generate error.
Inputs in degree
We can convert radian value to degree and use the same
import math
in_degree = 57
in_redian = math.radians(in_degree)
print(math.acos(in_redian))
Output
0.10165406130640683
1 radian = 57.2957914331 degree
1 degree = 0.0174533 radian
Drawing graph of acos()
In our Trigonometric language acos is also know as arccos. Using this we will use Matplotlib to generate graph of acos
import matplotlib.pyplot as plt
import math
x=[]
y=[]
i=-1
while (i<=1):
x.append(i)
y.append(math.acos(i))
i=i+0.01
plt.plot(x,y)
plt.show()
← Subscribe to our YouTube Channel here
This article is written by plus2net.com team.
https://www.plus2net.com
plus2net.com