Below is the example of the Math acos( ) Method.
- Example:
<script type="text/javascript">document.write("When 1 is passed as a parameter: "+ Math.acos(1));</script>chevron_rightfilter_none - Output:
When 1 is passed as a parameter: 0
The Math.acos( ) method is used to return the arccosine of a number in radians. The Math.acos() method returns a numeric value between 0 and pi radians. The Math acos() is a static method of Math, therefore, it is always used as Math.acos(), rather than as a method of a Math object created.
Math.acos(x)=arccos(x)=unique y,
where y belongs to [0;pi]
such that cos(y)=x
Syntax:
Math.acos(value)
Parameters: This function accepts single parameter as mentioned above and described below:
- value which is a number in radians who arccosine you want to find.
Returns: The Math.acos() function returns the arccosine of the given number in radians.
Below examples illustrate the Math acos( ) method in JavaScript:
- Example 1:
Input : Math.acos(1) Output : 0
- Example 2:
Input : Math.acos(-1) Output : 3.141592653589793
- Example 3:
Input : Math.acos(0) Output: 1.5707963267948966
More example codes for the above method are as follows:
Program 1:
<script type="text/javascript"> document.write("When -1 is passed as a parameter: " + Math.acos(-1)); </script> |
Output:
When 1 is passed as a parameter: 3.141592653589793
Prgram 2:
<script type="text/javascript"> document.write("When 0 is passed as a parameter: " + Math.acos(0)); </script> |
Output:
When 0 is passed as a parameter: 1.5707963267948966
Prgram 3:
<script type="text/javascript"> document.write("When 0.5 is passed as a parameter: " + Math.acos(0.5)); </script> |
Output:
When 0.5 is passed as a parameter: 1.0471975511965979
Prgram 4:
<script type="text/javascript"> document.write("When 2 is passed as a parameter: " + Math.acos(2)); </script> |
Output:
When 2 is passed as a parameter: NaN
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- JavaScript Math sin( ) Method
- JavaScript Math max() Method
- JavaScript Math log( ) Method
- JavaScript Math exp( ) Method
- JavaScript Math cos( ) Method
- JavaScript Math tan( ) Method
- JavaScript Math pow( ) Method
- JavaScript Math abs( ) Method
- JavaScript Math min( ) Method
- JavaScript Math acosh() Method
- JavaScript Math asinh() Method
- JavaScript Math trunc( ) Method
- JavaScript Math floor() Method
- JavaScript Math sqrt( ) Method
- JavaScript Math round( ) Method
- JavaScript Math random() Method
- JavaScript Math tanh() Method
- JavaScript Math cosh() Method
- JavaScript Math atan2( ) Method
- JavaScript Math cbrt() Method
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.


