JavaScript Math.sinh() method
The Math.sinh() method in JavaScript allows a numeric value as an argument and returns the hyperbolic sine of that number. If we provide Infinity and -Infinity as argument, this method returns Infinity and -Infinity, respectively. If a non-numeric or empty number is provided, it NaN as result.
Mathematically, the hyperbolic sine function is defined as follows −
sinh(x) = (e^x - e^(-x)) / 2
Where x is the number for which the hyperbolic sine is to be calculated, and e represents Euler's number, the base of the natural logarithm.
Syntax
Following is the syntax of JavaScript Math.sinh() method −
Math.sinh(x)
Parameters
This method accepts only one paramter. The same is described below −
- x: A numeric value.
Return value
This method returns the hyperbolic sine of the provided number.
Example 1
In the below example, we are using the JavaScript Math.sinh() method to calculate the hyperbolic sine of the provided number −
<html> <body> <script> let number1 = Math.sinh(-1); document.write(number1, "<br>"); let number2 = Math.sinh(0); document.write(number2, "<br>"); let number3 = Math.sinh(1); document.write(number3); </script> </body> </html>
Output
As we can see in the output, it returned the hyperbolic sine of the provided numbers.
Example 2
In this example below, we are using the Math.tanh() method with Infinity values −
<html> <body> <script> let number1 = Math.sinh(Infinity); document.write(number1, "<br>"); let number2 = Math.sinh(-Infinity); document.write(number2); </script> </body> </html>
Output
If we execute the above program, it returns Infinity and -Infinity as result, respectively.
Example 3
Here, we are trying to calculate the hyperbolic tangent value of a non-numeric value or empty number −
<html>
<body>
<script>
let number1 = Math.sinh("Tutorialspoint");
document.write(number1, "<br>");
let number2 = Math.sinh();
document.write(number2);
</script>
</body>
</html>
Output
If we execute the above program, it returns NaN as result.