Java Math acos() Method Last Updated : 07 May, 2025 Summarize Comments Improve Suggest changes Share Like Article Like Report 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.Syntax of Math acos() Methodpublic static double acos(double a)Parameter: a: The value whose arc cosine is to be returned.Return: This method returns the arc cosine of the argument.Important Points:Our input should be only between -1.0 and 1.0. The values outside this range will result in NaN.If |a| > 1 or a is NaN, the method returns NaN.Any value whose absolute value exceeds 1, results NaN.Examples of Java Math acos() MethodExample 1: Input Outside [-1, 1] Java // Java program to demonstrate // Math.acos() with invalid input public class Geeks { public static void main(String[] args) { double a = Math.PI; System.out.println(Math.acos(a)); } } OutputNaN 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 Java // Java program to convert // degrees to radians before using acos() public class Geeks { public static void main(String[] args) { double d = Math.PI; double r = Math.toRadians(d); System.out.println(Math.acos(r)); } } Output1.5159376794536454 Example 3: Different Valid and Invalid Inputs Java // Java program to show Math.acos() for multiple values public class Geeks { public static void main(String[] args) { double[] values = {1.0, 0.0, -1.0, 1.5}; for (double v : values) { System.out.println("acos(" + v + ") = " + Math.acos(v)); } } } Outputacos(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. Comment More infoAdvertise with us N Niraj_Pandey Follow Improve Article Tags : Java Java-lang package java-math Practice Tags : Java Similar Reads Java Math acos() method with Examples 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.Syntax of Math acos() Methodpublic static double acos(double a)Parameter: a 2 min read java.math class and its methods | Set 3 java.math class and its methods | Set 1 java.math class and its methods | Set 2 ceil() : java.math.ceil(double a) method returns the smallest possible value which is either greater or equal to the argument passed. The returned value is a mathematical integer.Special Case : Result is same, if the ret 5 min read java.math class and its methods | Set 1 Math class provides mathematical functions to perform basic numeric operations such as exponential, logarithm, square root, and trigonometric functions. cosh, sin, tan, abs, bitLength, multiply and many more. Implementations of the functions of Math class do not return bit-for-bit same results. Henc 4 min read StrictMath acos() Method in Java The java.lang.StrictMath.acos() is an inbuilt method which returns cosine of a given argument and an angle. The angle which is returned within the range between 0.0 and pi. Note: If the absolute value of the argument is greater than 1 or the argument is itself a NaN then the result is also NaN. Synt 2 min read Java Math Class Java.lang.Math Class methods help to perform numeric operations like square, square root, cube, cube root, exponential and trigonometric operations.Declarationpublic final class Math extends Object Methods of Math Class in JavaMath class consists of methods that can perform mathematical operations a 7 min read Like