JavaScript Math.atanh()

Posted by

Introduction to JavaScript Math.atanh()

The Math.atanh() function is a JavaScript function that is used to calculate the inverse hyperbolic tangent of a given number. The inverse hyperbolic tangent of a number is defined as the value whose hyperbolic tangent is equal to the given number. In other words, the result of Math.atanh() is the angle whose hyperbolic tangent is equal to the given number.

Syntax of JavaScript Math.atanh()

The syntax of the Math.atanh() function is as follows:

[dm_code_snippet background=”yes” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

Math.atanh(x)

[/dm_code_snippet]

Here, x is a number whose inverse hyperbolic tangent needs to be calculated.

Return Value of JavaScript Math.atanh()

The Math.atanh() function returns the inverse hyperbolic tangent of a given number. The returned value is a number between -Infinity and +Infinity.

Examples of JavaScript Math.atanh()

Here are some examples of using the Math.atanh() function:

[dm_code_snippet background=”yes” background-mobile=”yes” slim=”no” line-numbers=”no” bg-color=”#abb8c3″ theme=”dark” language=”php” wrapped=”no” height=”” copy-text=”Copy Code” copy-confirmed=”Copied”]

// Returns the inverse hyperbolic tangent of 0.5
Math.atanh(0.5);

// Returns the inverse hyperbolic tangent of -0.5
Math.atanh(-0.5);

// Returns the inverse hyperbolic tangent of 1
Math.atanh(1);

// Returns the inverse hyperbolic tangent of -1
Math.atanh(-1);

[/dm_code_snippet]

Note that the Math.atanh() function will throw an error if the given number is not between -1 and 1.

Conclusion

In this tutorial, we learned about the Math.atanh() function in JavaScript. This function is used to calculate the inverse hyperbolic tangent of a given number. We also learned about the syntax of Math.atanh() and its return value. Finally, we looked at some examples of using the Math.atanh() function.