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.

Die statische Methode Math.atanh() gibt den inversen hyperbolischen Tangens einer Zahl zurück. Das bedeutet:

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}

Probieren Sie es aus

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

Syntax

js
Math.atanh(x)

Parameter

x

Eine Zahl zwischen -1 und 1, einschließlich.

Rückgabewert

Der inverse hyperbolische Tangens von x. Wenn x 1 ist, wird Infinity zurückgegeben. Wenn x -1 ist, wird -Infinity zurückgegeben. Wenn x kleiner als -1 oder größer als 1 ist, wird NaN zurückgegeben.

Beschreibung

Da atanh() eine statische Methode von Math ist, wird sie immer als Math.atanh() verwendet und nicht als Methode eines selbst erstellten Math-Objekts (da Math kein Konstruktor ist).

Beispiele

Verwendung von 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

Spezifikationen

Specification
ECMAScript® 2025 Language Specification
# sec-math.atanh

Browser-Kompatibilität

BCD tables only load in the browser

Siehe auch