JavaScript Math.acosh()
Syntax & Examples
Math.acosh() static-method
The Math.acosh() method in JavaScript returns the hyperbolic arccosine of a number. The method returns a value in the range [0, ∞) for x ≥ 1.
Syntax of Math.acosh()
The syntax of Math.acosh() static-method is:
Math.acosh(x)
This acosh() static-method of Math returns the hyperbolic arccosine of x.
Parameters
Parameter | Optional/Required | Description |
---|---|---|
x | required | A number greater than or equal to 1. If the value of x is less than 1, the method returns NaN. |
Return Type
Math.acosh() returns value of type Number
.
✐ Examples
1 Using Math.acosh() with a number greater than 1
In JavaScript, we can use the Math.acosh()
method to get the hyperbolic arccosine of a number greater than 1.
For example,
- We call the
Math.acosh()
method with a numberx
greater than 1. - The hyperbolic arccosine value is returned and stored in the variable
result
. - We log
result
to the console usingconsole.log()
method.
JavaScript Program
const x = 2;
const result = Math.acosh(x);
console.log(result);
Output
1.3169578969248166
2 Using Math.acosh() with 1
In JavaScript, we can use the Math.acosh()
method to get the hyperbolic arccosine of 1.
For example,
- We call the
Math.acosh()
method with 1x
. - The hyperbolic arccosine value is returned and stored in the variable
result
. - We log
result
to the console usingconsole.log()
method.
JavaScript Program
const x = 1;
const result = Math.acosh(x);
console.log(result);
Output
0
3 Using Math.acosh() with a number less than 1
In JavaScript, we can use the Math.acosh()
method to try to get the hyperbolic arccosine of a number less than 1, which returns NaN.
For example,
- We call the
Math.acosh()
method with a numberx
less than 1. - The method returns NaN and the result is stored in the variable
result
. - We log
result
to the console usingconsole.log()
method.
JavaScript Program
const x = 0.5;
const result = Math.acosh(x);
console.log(result);
Output
NaN
Summary
In this JavaScript tutorial, we learned about acosh() static-method of Math: the syntax and few working examples with output and detailed explanation for each example.