Math.acos( ) In JavaScript
The Math.acos( ) function in JavaScript is used to return the arccosine of a number in radians.
Math.acos(x)=arccos(x)=unique y, where y belongs to [0;pi] such that cos(y)=x
The Math.acos() method returns a numeric value between 0 and pi radians.
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.
Syntax:
Math.acos(value)
Parameters: This function accepts single parameter 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.
Examples:
Input : Math.acos(1) Output : 0 Input : Math.acos(-1) Output : 3.141592653589793 Input : Math.acos(0) Output : 1.5707963267948966 Input : Math.acos(0.5) Output : 1.0471975511965979 Input : Math.acos(2) Output : NaN
- Example 1: When 1 is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.acos(1));
</
script
>
chevron_rightfilter_noneOutput:
Output : 0
- Example 2: When -1 is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.acos(-1));
</
script
>
chevron_rightfilter_noneOutput:
Output : 3.141592653589793
- Example 3: When 0 is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.acos(0));
</
script
>
chevron_rightfilter_noneOutput:
Output : 1.5707963267948966
- Example 4: When 0.5 is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.acos(0.5));
</
script
>
chevron_rightfilter_noneOutput:
Output : 1.0471975511965979
- Example 5: When 2 is passed as a parameter.
<
script
type
=
"text/javascript"
>
document.write("Output : " + Math.acos(2));
</
script
>
chevron_rightfilter_noneOutput:
Output : NaN
Supported Browsers: The browsers supported by JavaScript Math.acos( ) function are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- Introduction to JavaScript Course | Learn how to Build a task tracker using JavaScript
- How to compare two JavaScript array objects using jQuery/JavaScript ?
- JavaScript Course | Understanding Code Structure in JavaScript
- JavaScript Course | Conditional Operator in JavaScript
- JavaScript Course | Data Types in JavaScript
- JavaScript Course | Printing Hello World in JavaScript
- JavaScript Course | Logical Operators in JavaScript
- JavaScript Course | Operators in JavaScript
- JavaScript Course | Functions in JavaScript
- JavaScript Course | Objects in JavaScript
- JavaScript Course | Loops in JavaScript
- JavaScript Course | Variables in JavaScript
- JavaScript Course | JavaScript Prompt Example
- JavaScript vs Python : Can Python Overtop JavaScript by 2020?
- How to include a JavaScript file in another JavaScript file ?
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.