JavaScript Math acosh()

The acosh() method computes the hyperbolic arc-cosine of the specified number and returns it.

Example

// hyperbolic arc-cosine of 5
let number = Math.acosh(5);
console.log(number); 

// Output: 2.2924316695611777

acosh() syntax

The syntax of the Math.acosh() method is:

Math.acosh(number)

Here, acosh() is a static method. Hence, we are accessing the method using the class name, Math.


acosh() Parameter

The acosh() method takes a single parameter:

  • number - a positive value whose hyperbolic arc-cosine is to be calculated

acosh() Return Value

The acosh() method returns:

  • hyperbolic arc-cosine of the given positive argument number
  • NaN (Not a Number) for zero, negative and non-numeric argument

Example 1: JavaScript Math.acosh() with Positive Numbers

// hyperbolic arc-cosine of an integer let result1 = Math.acosh(32);
console.log(result1);
// hyperbolic arc-cosine of a floating-point number let result2 = Math.acosh(4.5);
console.log(result2); // Output: // 4.158638853279167 // 2.1846437916051085

In the above example, we have used the Math.acosh() method with

  • 32 (integer value) - results in 4.158638853279167
  • 4.5 (floating-point value) - result in 2.1846437916051085

Example 2: Math.acosh() with Zero and Negative Numbers

// hyperbolic arc-cosine of a negative number let result1 = Math.acosh(-12.5);
console.log(result1); // Output: NaN
// hyperbolic arc-cosine of zero let result2 = Math.acosh(0)
; console.log(result2); // Output: NaN

In the above example, we have used the acosh() method with a negative number and zero. For both values, we get NaN as output.

Note: We can only use the acosh() method with positive numbers.


Example 3: Math.acosh() with Non-Numeric argument

let string ="Harry";
// acosh() with a string argument let value = Math.acosh(string);
console.log(value); // Output: NaN

In the above example, we have used the acosh() method with the string "Harry". Hence, we get NaN as output.


Also Read:

Did you find this article helpful?

Our premium learning platform, created with over a decade of experience and thousands of feedbacks.

Learn and improve your coding skills like never before.

Try Programiz PRO
  • Interactive Courses
  • Certificates
  • AI Help
  • 2000+ Challenges