From 4b1a9203c547c019fc5398082ae19a3f3d4c3efe Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:41:15 -0500 Subject: initial commit --- .../objectes_globals/math/tanh/index.html | 142 +++++++++++++++++++++ 1 file changed, 142 insertions(+) create mode 100644 files/ca/web/javascript/referencia/objectes_globals/math/tanh/index.html (limited to 'files/ca/web/javascript/referencia/objectes_globals/math/tanh/index.html') diff --git a/files/ca/web/javascript/referencia/objectes_globals/math/tanh/index.html b/files/ca/web/javascript/referencia/objectes_globals/math/tanh/index.html new file mode 100644 index 0000000000..ada19d17e0 --- /dev/null +++ b/files/ca/web/javascript/referencia/objectes_globals/math/tanh/index.html @@ -0,0 +1,142 @@ +--- +title: Math.tanh() +slug: Web/JavaScript/Referencia/Objectes_globals/Math/tanh +translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh +--- +
{{JSRef}}
+ +

La funció Math.tanh() retorna la tangent hiperbòlica d'un nombre, és a dir

+ +

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}

+ +

Sintaxi

+ +
Math.tanh(x)
+ +

Paràmetres

+ +
+
x
+
Un nombre.
+
+ +

Descripció

+ +

Com que que tanh() és un mètode estàtic de Math, sempre s'utilitza com a Math.tanh(), en comptes de com a mètode d'una instància de Math (Math no és un constructor).

+ +

Exemples

+ +

Utilitzar Math.tanh()

+ +
Math.tanh(0);        // 0
+Math.tanh(Infinity); // 1
+Math.tanh(1);        // 0.7615941559557649
+
+ +

Polyfill

+ +

Aquest comportament pot emular-se amb l'ajuda de la funció {{jsxref("Math.exp()")}}:

+ +
Math.tanh = Math.tanh || function(x) {
+  if (x === Infinity) {
+    return 1;
+  } else if (x === -Infinity) {
+    return -1;
+  } else {
+    return (Math.exp(x) - Math.exp(-x)) / (Math.exp(x) + Math.exp(-x));
+  }
+}
+
+ +

o bé utilitzant només una crida a {{jsxref("Math.exp()")}}:

+ +
Math.tanh = Math.tanh || 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);
+  }
+}
+
+ +

Especificacions

+ + + + + + + + + + + + + + +
EspecificacióEstatComentaris
{{SpecName('ES6', '#sec-math.tanh', 'Math.tanh')}}{{Spec2('ES6')}}Definició inicial.
+ +

Compatibilitat amb navegadors

+ +
{{CompatibilityTable}}
+ +
+ + + + + + + + + + + + + + + + + + + +
CaracterísticaChromeFirefox (Gecko)Internet ExplorerOperaSafari
Suport bàsic{{CompatChrome("38")}}{{CompatGeckoDesktop("25")}}{{CompatNo}}{{CompatOpera("25")}}{{CompatSafari("7.1")}}
+
+ +
+ + + + + + + + + + + + + + + + + + + + + +
CaracterísticaAndroidChrome for AndroidFirefox Mobile (Gecko)IE MobileOpera MobileSafari Mobile
Suport bàsic{{CompatNo}}{{CompatNo}}{{CompatGeckoMobile("25")}}{{CompatNo}}{{CompatNo}}8
+
+ +

Vegeu també

+ + -- cgit v1.2.3-54-g00ecf