![]() |
VOOZH | about |
The Math.acos() method returns the arc cosine of an angle between 0.0 and pi (0.0, pi). Arc cosine is also called as inverse of a cosine. If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
public static double acos(double a)
Important Points:
Example 1: Input Outside [-1, 1]
NaN
Explanation: In this example, Math.PI i.e., ~3.14 is outside the valid domain so the result is NaN.
Example 2: Convert Degrees to Radians
1.5159376794536454
Example 3: Different Valid and Invalid Inputs
acos(1.0) = 0.0 acos(0.0) = 1.5707963267948966 acos(-1.0) = 3.141592653589793 acos(1.5) = NaN
This method is useful in trigonometric calculations when we need the angle whose cosine is a given value.