JavaScript: Math cosh() function
This JavaScript tutorial explains how to use the math function called cosh() with syntax and examples.
Description
In JavaScript, cosh() is a function that is used to return the hyperbolic cosine of a number. Because the cosh() function is a static function of the Math object, it must be invoked through the placeholder object called Math.
Syntax
In JavaScript, the syntax for the cosh() function is:
Math.cosh(number);
Parameters or Arguments
- number
- The number used to calculate the hyperbolic cosine.
Returns
The cosh() function returns the hyperbolic cosine of a number.
Note
- Math is a placeholder object that contains mathematical functions and constants of which cosh() is one of these functions.
Example
Let's take a look at an example of how to use the cosh() function in JavaScript.
For example:
console.log(Math.cosh(0.8));
console.log(Math.cosh(1));
console.log(Math.cosh(-5));
In this example, we have invoked the cosh() function using the Math class.
We have written the output of the cosh() function to the web browser console log, for demonstration purposes, to show what the cosh() function returns.
The following will be output to the web browser console log:
1.3374349463048447 1.5430806348152437 74.20994852478785
In this example, the first output to the console log returned 1.3374349463048447 which is the hyperbolic cosine of 0.8.
The second output to the console log returned 1.5430806348152437 which is the hyperbolic cosine of 1.
The third output to the console log returned 74.20994852478785 which is the hyperbolic cosine of -5.
Advertisements