JavaScript(JS) math method - atanh
The atanh
method in JavaScript's Math
object returns the hyperbolic arctangent of a number.
The hyperbolic arctangent function, also known as the inverse hyperbolic tangent function, is the inverse function of the hyperbolic tangent function. It is defined as:
atanh(x) = 0.5 * ln((1 + x) / (1 - x))
The atanh
method takes one argument, which is the number whose hyperbolic arctangent needs to be calculated. If the argument is not a number, it will be converted to one before the calculation. If the argument is NaN or outside the range of -1 to 1, NaN
will be returned.
Here's an example usage:
const x = 0.5; const atanhX = Math.atanh(x); console.log(atanhX); // 0.5493061443340548
In the above example, the hyperbolic arctangent of 0.5 is calculated using the Math.atanh
method and assigned to the atanhX
variable. The result is then logged to the console. Note that the result is in radians. If you want the result in degrees, you can convert it by multiplying it by 180 / Math.PI
.