--- title: Math.atanh() slug: Web/JavaScript/Reference/Global_Objects/Math/atanh tags: - JavaScript - Math - Méthode - Reference - polyfill translation_of: Web/JavaScript/Reference/Global_Objects/Math/atanh original_slug: Web/JavaScript/Reference/Objets_globaux/Math/atanh ---
La fonction Math.atanh() renvoie l'arc tangente hyperbolique d'un nombre :
Le code source de cet exemple interactif est disponible dans un dépôt GitHub. Si vous souhaitez contribuez à ces exemples, n'hésitez pas à cloner https://github.com/mdn/interactive-examples et à envoyer une pull request !
Math.atanh(x)
xL'arc tangente hyperbolique du nombre passé en argument.
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).
Math.atanh()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, {{jsxref("NaN")}} sera renvoyé.
Pour , on a la formule suivante : et on peut donc émuler la fonction avec :
Math.atanh = Math.atanh || function(x) {
return Math.log((1+x)/(1-x)) / 2;
};
| Spécification | Statut | Commentaires |
|---|---|---|
| {{SpecName('ES6', '#sec-math.atanh', 'Math.atanh')}} | {{Spec2('ES6')}} | Définition initiale. |
| {{SpecName('ESDraft', '#sec-math.atanh', 'Math.atanh')}} | {{Spec2('ESDraft')}} |
{{Compat("javascript.builtins.Math.atanh")}}