Math.atanh()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.

Phương thức tĩnh Math.atanh() trả về arctanh hyperbolic của một số. Cụ thể:

x(1,1),𝙼𝚊𝚝𝚑.𝚊𝚝𝚊𝚗𝚑(𝚡)=artanh(x)=the unique y such that tanh(y)=x=12ln(1+x1x)\begin{aligned}\forall x \in ({-1}, 1),\;\mathtt{\operatorname{Math.atanh}(x)} &= \operatorname{artanh}(x) = \text{the unique } y \text{ such that } \tanh(y) = x \\&= \frac{1}{2}\,\ln\left(\frac{1+x}{1-x}\right)\end{aligned}

Try it

console.log(Math.atanh(-1));
// Expected output: -Infinity

console.log(Math.atanh(0));
// Expected output: 0

console.log(Math.atanh(0.5));
// Expected output: 0.549306144334055 (approximately)

console.log(Math.atanh(1));
// Expected output: Infinity

Cú pháp

js
Math.atanh(x)

Tham số

x

Một số trong khoảng từ -1 đến 1 (bao gồm hai đầu mút).

Giá trị trả về

Arctanh hyperbolic của x. Nếu x bằng 1, trả về Infinity. Nếu x bằng -1, trả về -Infinity. Nếu x nhỏ hơn -1 hoặc lớn hơn 1, trả về NaN.

Mô tả

atanh() là một phương thức tĩnh của Math, bạn luôn sử dụng nó dưới dạng Math.atanh(), thay vì là phương thức của một đối tượng Math bạn tạo ra (Math không phải là constructor).

Ví dụ

Sử dụng Math.atanh()

js
Math.atanh(-2); // NaN
Math.atanh(-1); // -Infinity
Math.atanh(-0); // -0
Math.atanh(0); // 0
Math.atanh(0.5); // 0.5493061443340548
Math.atanh(1); // Infinity
Math.atanh(2); // NaN

Đặc tả kỹ thuật

Thông số kỹ thuật
ECMAScript® 2027 Language Specification
# sec-math.atanh

Tương thích trình duyệt

Xem thêm