A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.mozilla.org/fr/docs/Web/JavaScript/Reference/Global_Objects/Math/cosh below:

Math.cosh() - JavaScript | MDN

Math.cosh()

Baseline Widely available

La fonction Math.cosh() renvoie le cosinus hyperbolique d'un nombre, défini par :

Math.cosh(x) = ex + e - x 2 \mathtt{\operatorname{Math.cosh(x)}} = \frac{e^x + e^{-x}}{2}

Exemple interactif
console.log(Math.cosh(0));
// Expected output: 1

console.log(Math.cosh(1));
// Expected output: 1.543080634815244 (approximately)

console.log(Math.cosh(-1));
// Expected output: 1.543080634815244 (approximately)

console.log(Math.cosh(2));
// Expected output: 3.7621956910836314

(Voir la page sur e)

Syntaxe Paramètres Valeur de retour

Le cosinus hyperbolique du nombre passé en argument.

Description

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

Exemple Utiliser Math.cosh()
Math.cosh(0); // 1
Math.cosh(1); // 1.5430806348152437
Math.cosh(-1); // 1.5430806348152437
Prothèse d'émulation (polyfill)

Cette fonction peut être émulée grâce à la fonction Math.exp() :

Math.cosh =
  Math.cosh ||
  function (x) {
    return (Math.exp(x) + Math.exp(-x)) / 2;
  };

On peut également utiliser un unique appel à exp() :

Math.cosh =
  Math.cosh ||
  function (x) {
    var y = Math.exp(x);
    return (y + 1 / y) / 2;
  };
Spécifications Compatibilité des navigateurs Voir aussi

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4