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. print(math.acos(1.01))
print(math.acos(-1.01))
Above code will generate error. import math
in_degree = 57
in_redian = math.radians(in_degree)
print(math.acos(in_redian))
Output
0.10165406130640683
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()
import math
try:
print(math.acos(1.5)) # Will raise ValueError
except ValueError as e:
print(e) # Output: math domain error
import math
a, b, c = 3, 4, 5 # sides of the triangle
angle_C = math.acos((a**2 + b**2 - c**2) / (2 * a * b))
print(math.degrees(angle_C)) # Output: 90.0 (degrees)
import math
cos_value = 0.5
angle = math.acos(cos_value)
print(angle) # Output: 1.0471975511965979 (in radians)
import math
cos_value = math.cos(math.pi / 3) # cos(60 degrees)
angle = math.acos(cos_value)
print(angle) # Output: 1.0471975511965979 (radians, which is 60 degrees)
import math
force_angle_cos = 0.866 # Cosine of angle between two forces
angle = math.acos(force_angle_cos)
print(math.degrees(angle)) # Output: 30 degrees
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.