Java Math acos() method with Examples
The java.lang.Math.acos() returns the arc cosine of an angle in between 0.0 and 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 :
public 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.
Example :To show working of java.lang.Math.acos() method.
// Java program to demonstrate working // of java.lang.Math.acos() method import java.lang.Math; class Gfg { // driver code public static void main(String args[]) { double a = Math.PI; // Output is NaN, because Math.PI gives 3.141 value // greater than 1 System.out.println(Math.acos(a)); // convert Math.PI to radians double b = Math.toRadians(a); System.out.println(Math.acos(b)); double c = 1.0; double d = 0.0; double e = -1.0; double f = 1.5; System.out.println(Math.acos(c)); System.out.println(Math.acos(d)); System.out.println(Math.acos(e)); // value of f does not lie in between -1 and 1 // so output is NaN System.out.println(Math.acos(f)); } } |
chevron_right
filter_none
Output:
NaN 1.5159376794536454 0.0 1.5707963267948966 3.141592653589793 NaN
Recommended Posts:
- Math fma() method in Java with Examples
- Java Math min() method with Examples
- Java Math sin() method with Examples
- Java Math tan() method with Examples
- Java Math max() method with Examples
- Java Math cos() method with Examples
- Java Math abs() method with Examples
- Java Math ulp() method with Examples
- Math multiplyFull() method in Java with Examples
- Java Math nextDown() method with Examples
- Math multiplyHigh() method in Java with Examples
- Java Math copySign() method with Examples
- Java Math sinh() method with Examples
- Java Math nextUp() method with Examples
- Java Math IEEEremainder() method with Examples
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



