## Java Math acos()

acos() accepts double value as an argument and returns arc cosine of the argument value. The returned value is also of type double.

If the argument is NaN or its absolute value is greater than 1, then acos() returns NaN.

Following is the syntax of acos() method.

`double radians = acos(double value)`

### Example 1 – Math.acos(double)

In the following example, we pass a double value within the range [-1, 1] as argument to acos() method and find its value.

Java Program

```public class MathExample {
public static void main(String[] args) {
double x = 0.75;
double a = Math.acos(x);
System.out.println(a);
}
}```

Output

`0.7227342478134157 radians`

### Example 2 – Math.acos() – Argument Value that is Out of Valid Range

In the following example, we pass a double value outside of the range [-1, 1] as argument to acos() method. As per the definition of the function, it should return NaN value.

Java Program

```public class MathExample {
public static void main(String[] args) {
double x = 2.75;
double a = Math.acos(x);
System.out.println(a);
}
}```

Output

`NaN`

### Example 3 – Math.acos(NaN)

In the following example, we pass Double.NaN as argument to acos() method. As per the definition of the function, acos() should return NaN value.

Java Program

```public class MathExample {
public static void main(String[] args) {
double x = Double.NaN;
double a = Math.acos(x);
System.out.println(a);
}
}```

Output

`NaN`

### Conclusion

In this Java Tutorial, we learned about Java Math.acos() function, with example programs.