aboutsummaryrefslogtreecommitdiff
path: root/files/de/web/javascript/reference/global_objects/math/tanh/index.html
blob: e13d8f9e14dd62e31faea9180230fb7b955113e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
---
title: Math.tanh()
slug: Web/JavaScript/Reference/Global_Objects/Math/tanh
tags:
  - ECMAScript 2015
  - JavaScript
  - Math
  - Method
  - Reference
translation_of: Web/JavaScript/Reference/Global_Objects/Math/tanh
---
<div>{{JSRef}}</div>

<p>Die <strong><code>Math.tanh()</code></strong> Funktion gibt den Tangens Hyperbolicus einer Zahl zurück. Dieser kann folgendermaßen errechnet werden:</p>

<p><math display="block"><semantics><mrow><mo lspace="0em" rspace="0em">tanh</mo><mi>x</mi><mo>=</mo><mfrac><mrow><mo lspace="0em" rspace="0em">sinh</mo><mi>x</mi></mrow><mrow><mo lspace="0em" rspace="0em">cosh</mo><mi>x</mi></mrow></mfrac><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>-</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow><mrow><msup><mi>e</mi><mi>x</mi></msup><mo>+</mo><msup><mi>e</mi><mrow><mo>-</mo><mi>x</mi></mrow></msup></mrow></mfrac><mo>=</mo><mfrac><mrow><msup><mi>e</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup><mo>-</mo><mn>1</mn></mrow><mrow><msup><mi>e</mi><mrow><mn>2</mn><mi>x</mi></mrow></msup><mo>+</mo><mn>1</mn></mrow></mfrac></mrow><annotation encoding="TeX">\tanh x = \frac{\sinh x}{\cosh x} = \frac {e^x - e^{-x}} {e^x + e^{-x}} = \frac{e^{2x} - 1}{e^{2x}+1}</annotation></semantics></math></p>

<div>{{EmbedInteractiveExample("pages/js/math-tanh.html")}}</div>

<h2 id="Syntax">Syntax</h2>

<pre class="syntaxbox"><code>Math.tanh(<var>x</var>)</code></pre>

<h3 id="Parameter">Parameter</h3>

<dl>
 <dt><code>x</code></dt>
 <dd>Eine Zahl.</dd>
</dl>

<h3 id="Rückgabewert">Rückgabewert</h3>

<p>Den Tangens Hyperbolicus der übergebenen Zahl.</p>

<h2 id="Beschreibung">Beschreibung</h2>

<p>Weil <code>tanh()</code> eine statische Funktion von <code>Math</code> ist, wird es immer als <code>Math.tanh()</code> eingesetzt<code>,</code> jedoch nicht als Methode eines erzeugten <code>Math</code> Objektes (<code>Math</code> ist kein Konstruktor).</p>

<h2 id="Beispiele">Beispiele</h2>

<h3 id="Einsatz_von_Math.tanh()">Einsatz von <code>Math.tanh()</code></h3>

<pre class="brush: js">Math.tanh(0);        // 0
Math.tanh(Infinity); // 1
Math.tanh(1);        // 0.7615941559557649
</pre>

<h2 id="Polyfill">Polyfill</h2>

<p>Diese Funktion kann mit Hilfe der Funktion {{jsxref("Math.exp()")}} emuliert werden:</p>

<pre class="brush: js line-numbers  language-js"><code class="language-js">Math<span class="punctuation token">.</span>tanh <span class="operator token">=</span> Math<span class="punctuation token">.</span>tanh <span class="operator token">||</span> <span class="keyword token">function</span><span class="punctuation token">(</span>x<span class="punctuation token">)</span><span class="punctuation token">{</span>
    <span class="keyword token">var</span> a <span class="operator token">=</span> Math<span class="punctuation token">.</span><span class="function token">exp</span><span class="punctuation token">(</span><span class="operator token">+</span>x<span class="punctuation token">)</span><span class="punctuation token">,</span> b <span class="operator token">=</span> Math<span class="punctuation token">.</span><span class="function token">exp</span><span class="punctuation token">(</span><span class="operator token">-</span>x<span class="punctuation token">)</span><span class="punctuation token">;</span>
    <span class="keyword token">return</span> a <span class="operator token">==</span> <span class="number token">Infinity</span> <span class="operator token">?</span> <span class="number token">1</span> <span class="punctuation token">:</span> b <span class="operator token">==</span> <span class="number token">Infinity</span> <span class="operator token">?</span> <span class="operator token">-</span><span class="number token">1</span> <span class="punctuation token">:</span> <span class="punctuation token">(</span>a <span class="operator token">-</span> b<span class="punctuation token">)</span> <span class="operator token">/</span> <span class="punctuation token">(</span>a <span class="operator token">+</span> b<span class="punctuation token">)</span><span class="punctuation token">;</span>
<span class="punctuation token">}</span></code></pre>

<h2 id="Spezifikationen">Spezifikationen</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Spezifikation</th>
   <th scope="col">Status</th>
   <th scope="col">Kommentar</th>
  </tr>
  <tr>
   <td>{{SpecName('ES2015', '#sec-math.tanh', 'Math.tanh')}}</td>
   <td>{{Spec2('ES2015')}}</td>
   <td>Initiale Definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-math.tanh', 'Math.tanh')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="Browserkompatibilität">Browserkompatibilität</h2>

<p>{{Compat("javascript.builtins.Math.tanh")}}</p>

<h2 id="Siehe_auch">Siehe auch</h2>

<ul>
 <li>{{jsxref("Math.acosh()")}}</li>
 <li>{{jsxref("Math.asinh()")}}</li>
 <li>{{jsxref("Math.atanh()")}}</li>
 <li>{{jsxref("Math.cosh()")}}</li>
 <li>{{jsxref("Math.sinh()")}}</li>
</ul>