Math.atanh()

La fonction Math.atanh() renvoie l'arc tangente hyperbolique d'un nombre :

x ( - 1 , 1 ) , Math.atanh ( x ) = arctanh ( x ) = le seul y tel que tanh ( y ) = x \forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } ; y ; \text{such that} ; \tanh(y) = x

Exemple interactif

Syntaxe

js
Math.atanh(x);

Paramètres

x

Un nombre.

Valeur de retour

L'arc tangente hyperbolique du nombre passé en argument.

Description

atanh() est une méthode statique de Math, il faut utiliser la syntaxe Math.atanh(), et non pas une méthode d'un objet Math créé sur mesure (Math n'est pas un constructeur).

Exemple

Utiliser Math.atanh()

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

Pour les valeurs strictement inférieures à -1 ou strictement supérieures à 1, NaN sera renvoyé.

Prothèse d'émulation (polyfill)

Pour | x | < 1 \left|x\right| < 1 , on a la formule suivante : artanh ( x ) = 1 2 ln ( 1 + x 1 - x ) \operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right) et on peut donc émuler la fonction avec :

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

Spécifications

Specification
ECMAScript Language Specification
# sec-math.atanh

Compatibilité des navigateurs

BCD tables only load in the browser

Voir aussi