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.

La función Math.atanh() nos retorna un arco hiperbólico de un numero, eso es:

x(-1,1),Math.atanh(x)=arctanh(x)= the unique ysuch thattanh(y)=x\forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ el unico } ; y ; \text{de tal manera que} ; \tanh(y) = x

Pruébalo

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

Sintaxis

Math.atanh(x)

Parametros

x

Un numero.

Retorna un valor

El arco hiperbolico tangible nos otorga un numero.

Descripción

Por que atanh() es un metodo estatico de Math, tu siempre puedes usar eso como Math.atanh(), se puede usar como un metod de Math objeto que tu creaste (Math no es un constructor).

Polimorfismo

Para |x|<1\left|x\right| < 1, tenemos artanh(x)=12ln(1+x1-x)\operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right) por lo que esto puede estar emulado con la siguiente función:

js
Math.atanh =
  Math.atanh ||
  function (x) {
    return Math.log((1 + x) / (1 - x)) / 2;
  };

Ejemplos

Using Math.atanh()

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

Para valores mayores a 1 o menores a -1, NaN retorna.

Especificaciones

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

Compatibilidad con navegadores

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
atanh

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Puedes leer