Below is the example of the Math cos() Method.
- Example:
<scripttype="text/javascript">document.write("The cos of 0 : " + Math.cos(0));</script>chevron_rightfilter_none - Output:
The cos of 0 : 1
The Math.cos() method is used to return the cosine of a number. The Math.cos() method returns a numeric value between -1 and 1, which represents the cosine of the angle given in radians. The cos() is a static method of Math, therefore, it is always used as Math.cos(), rather than as a method of a Math object created.
Syntax:
Math.cos(value)
Parameters: This function accepts single parameter as mentioned above and described below:
- value: This parameter is a number given in radians.
Returns: The Math.cos() function returns the cosine of the given numbers which range from -1 to 1.
Below example illustrate the cos() method in JavaScript:
- Example 1:
Input: Math.cos(010) Output : -0.14550003380861354
- Example 2:
Input: Math.cos(10) Output : -0.8390715290764524
More codes for the above method are as follows:
Program 1: When 1 is passed as a parameter.
<script type="text/javascript"> document.write("Result : " + Math.cos(1)); </script> |
Output:
Result : 0.5403023058681398
Program 2: When PI is passed as a parameter.
<script type="text/javascript"> document.write("Result : " + Math.cos(Math.PI)); </script> |
Output:
Result : -1
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Recommended Posts:
- JavaScript Math min( ) Method
- JavaScript Math pow( ) Method
- JavaScript Math max() Method
- JavaScript Math tan( ) Method
- JavaScript Math abs( ) Method
- JavaScript Math exp( ) Method
- JavaScript Math log( ) Method
- JavaScript Math sin( ) Method
- JavaScript Math ceil( ) Method
- JavaScript Math sqrt( ) Method
- JavaScript Math atan2( ) Method
- JavaScript Math atan( ) Method
- JavaScript Math atanh( ) Method
- JavaScript Math round( ) Method
- JavaScript Math acos( ) Method
- JavaScript Math asinh() Method
- JavaScript Math random() Method
- JavaScript Math asin( ) Method
- JavaScript Math cbrt() Method
- JavaScript Math floor() 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.
Improved By : skyridetim


