Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

javascript
math
atanh
communitycreator

What is Math.atanh() in JavaScript?

Arslan Bajwa

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code

In JavaScript, Math is a built-in object that contains different methods and properties used to perform mathematical operations. It contains an atanh() function, which is used to compute the hyperbolic arc-tangent of a specified number. This is also known as the inverse hyperbolic tangent.

Syntax

Math.atanh(param);

Parameter

  • param: This is the number for which we want to compute the hyperbolic arc-tangent. Its type is Number and it is measured in radians. Its range is:
    • -1 < param < 1

Number in JavaScript is a 64-bit double-precision value which is the same as double in C# or Java.

Return value

  • Number: It returns the angle whose hyperbolic cosine is equal to param. It is of the Number type.

  • NaN: The function returns this if param < -1 or param > 1.

  • +Infinity: The function returns this if param is 1.

  • -Infinity: The function returns this if param is -1.

Convert degrees to radians with the following formula:

  • Degrees = Radians x 180 / π

where π = 3.14159, approximately

Example

console.log("atanh(-1) = " + Math.atanh(-1));
console.log("atanh(0.5) = " + Math.atanh(0.5));
console.log("atanh(1) = " + Math.atanh(1));
console.log("atanh(∞) = " + Math.atanh(Infinity));
console.log("atanh(-∞) = " + Math.atanh(-Infinity));

RELATED TAGS

javascript
math
atanh
communitycreator

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Answers Code
Keep Exploring