JavaScript Math.acosh() Method



The Math.acosh() method in JavaScript is used to calculate the hyperbolic arc cosine of a number. It returns the inverse hyperbolic cosine (also known as area hyperbolic cosine) of a given numeric value. This method returns NaN, if the argument is less than 1, as the hyperbolic arccosine is undefined for values less than 1.

The formula for the inverse hyperbolic cos function is −

acosh(x) = ln(x + (x^2 - 1))

Here, "x" The input value for which we want to find the inverse hyperbolic cos.

Syntax

Following is the syntax of JavaScript Math.acosh() method −

Math.acosh(x)

Parameters

This method accepts only one parameter. The same is described below −

  • x: A numeric value.

Return value

This method returns a numeric value representing the hyperbolic arccosine of the given number x.

Example 1

In the example below, we are using the JavaScript Math.acosh() method to calculate the inverse hyperbolic cosine of 0 and -Infinity −

<html>
<body>
<script>
   const result1 = Math.acosh(0);
   const result2 = Math.acosh(-Infinity);
   document.write(result1, <br>, result2);
</script>
</body>
</html>

Output

It returns NaN as result because the provided numbers are less than 1.

Example 2

Here, we are calculating the inverse hyperbolic cosine of 1 −

<html>
<body>
<script>
   const result = Math.acosh(1);
   document.write(result);
</script>
</body>
</html>

Output

If we execute the above program, it returns 0 as result.

Example 3

In the below example, we are retrieving the inverse hyperbolic cosine of "2" and "Infinity" −

<html>
<body>
<script>
   const result1 = Math.acosh(2);
   const result2 = Math.acosh(Infinity);
   document.write(result1, <br>, result2);
</script>
</body>
</html>

Output

If we execute the above program, it returns 1.316 and Infinity, repectively.

Advertisements