| [ Web Proxy ] |
| Viewing: https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Math/tanh | [Back] [Original] |
Get to know MDN better
Cette page a t traduite partir de l'anglais par la communaut. Vous pouvez contribuer en rejoignant la communaut francophone sur MDN Web Docs.
Cette fonctionnalit est bien tablie et fonctionne sur de nombreux appareils et versions de navigateurs. Elle est disponible sur tous les navigateurs depuis juillet 2015.
La fonction Math.tanh() renvoie la tangente hyperbolique d'un nombre dfinie par :
tanhx=sinhxcoshx=ex-e-xex+e-x=e2x-1e2x+1\tanh x = \frac{\sinh x}{\cosh x} = \frac {e^x - e^{-x}} {e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x}+1}
console.log(Math.tanh(-1));
// Expected output: -0.7615941559557649
console.log(Math.tanh(0));
// Expected output: 0
console.log(Math.tanh(Infinity));
// Expected output: 1
console.log(Math.tanh(1));
// Expected output: 0.7615941559557649
Math.tanh(x);
xUn nombre.
La tangente hyperbolique du nombre fourni en argument.
tanh() est une mthode statique de l'objet Math, elle doit toujours tre utilise avec la syntaxe Math.tanh(), elle ne doit pas tre utilise comme une mthode d'un objet Math qui aurait t instanci (Math n'est pas une constructeur).
Math.tanh()Math.tanh(0); // 0
Math.tanh(Infinity); // 1
Math.tanh(1); // 0.7615941559557649
Cette mthode peut tre mule grce la fonction Math.exp() :
Math.tanh =
Math.tanh ||
function (x) {
var a = Math.exp(+x),
b = Math.exp(-x);
return a == Infinity ? 1 : b == Infinity ? -1 : (a - b) / (a + b);
};
et si on souhaite n'utiliser qu'un seul appel Math.exp() :
Math.tanhx =
Math.tanhx ||
function (x) {
if (x === Infinity) {
return 1;
} else if (x === -Infinity) {
return -1;
} else {
var y = Math.exp(2 * x);
return (y - 1) / (y + 1);
}
};
| Spcification |
|---|
| ECMAScript 2027 LanguageSpecification # sec-math.tanh |
Cette page a t modifie le 22 mai 2026 par les contributeurices du MDN.
Mathabs()acos()acosh()asin()asinh()atan()atan2()atanh()cbrt()ceil()clz32()cos()cosh()Math.exp()Math.expm1()f16round()Math.floor()Math.fround()Math.hypot()Math.imul()Math.log()Math.log1p()Math.log2()Math.log10()Math.max()Math.min()Math.pow()Math.random()Math.round()Math.sign()Math.sin()Math.sinh()Math.sqrt()sumPrecise()Math.tan()Math.tanh()Math.trunc()Certaines parties de ce contenu sont protges par le droit d'auteur 19982026 des contributeurs individuels de mozilla.org. Contenu disponible sous une licence Creative Commons.
| Web Proxy Viewer | New URL | Original Page |