diff options
Diffstat (limited to 'files/de/web/javascript/reference/global_objects/math/log/index.html')
| -rw-r--r-- | files/de/web/javascript/reference/global_objects/math/log/index.html | 113 |
1 files changed, 113 insertions, 0 deletions
diff --git a/files/de/web/javascript/reference/global_objects/math/log/index.html b/files/de/web/javascript/reference/global_objects/math/log/index.html new file mode 100644 index 0000000000..d4502d50e2 --- /dev/null +++ b/files/de/web/javascript/reference/global_objects/math/log/index.html @@ -0,0 +1,113 @@ +--- +title: Math.log() +slug: Web/JavaScript/Reference/Global_Objects/Math/log +tags: + - JavaScript + - Math + - Method + - Reference +translation_of: Web/JavaScript/Reference/Global_Objects/Math/log +--- +<div>{{JSRef}}</div> + +<p>Die <strong><code>Math.log()</code></strong> Funktion gibt den natürlichen Logarithmus (Logarithmus zur Basis {{jsxref("Math.E", "e")}}) einer Zahl zurück. Das bedeutet</p> + +<p><math display="block"><semantics><mrow><mo>∀</mo><mi>x</mi><mo>></mo><mn>0</mn><mo>,</mo><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.log</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="0em">ln</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mspace width="thickmathspace"></mspace><mi>y</mi><mspace width="thickmathspace"></mspace><mtext>sodass </mtext><mspace width="thickmathspace"></mspace><msup><mi>e</mi><mi>y</mi></msup><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\forall x > 0, \mathtt{\operatorname{Math.log}(x)} = \ln(x) = \text{the unique} \; y \; \text{such that} \; e^y = x</annotation></semantics></math></p> + +<p>Die JavaScript Function <strong><code>Math.log()</code> </strong>ist gleichbedeutend zu der mathematischen <em>Funktion ln(x)</em>.</p> + +<div>{{EmbedInteractiveExample("pages/js/math-log.html")}}</div> + + + +<h2 id="Syntax">Syntax</h2> + +<pre class="syntaxbox notranslate"><code>Math.log(<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>Der natürliche Logarithmus (Basis {{jsxref("Math.E", "e")}}) der übergebenen Zahl. Wenn die Zahl negativ ist, wird {{jsxref("NaN")}} zurückgegeben.</p> + +<h2 id="Beschreibung">Beschreibung</h2> + +<p>Wenn der Wert von <code>x</code> negativ ist, so gibt die Funktion immer {{jsxref("NaN")}} zurück.</p> + +<p>Weil <code>log()</code> eine statische Funktion von <code>Math</code> ist, wird es immer als <code>Math.log()</code> eingesetzt<code>,</code> jedoch nicht als Methode eines erzeugten <code>Math</code> Objektes (<code>Math</code> ist kein Konstruktor).</p> + +<p>Wenn der natürliche Logarithmus von 2 und 10 gebraucht wird, gibt es die Konstanten {{jsxref("Math.LN2")}} und {{jsxref("Math.LN10")}}. Wenn ein Logarithmus zur Basis 2 oder 10 gebracht wird, gibt es die Funktionen {{jsxref("Math.log2()")}} und {{jsxref("Math.log10()")}}. Wenn der Logarithmus zu einer anderen Basis gebraucht wird, benutzt man Math.log(x) / Math.log(andereBasis) wie im Beispiel unten. Manchmal möchte man 1 / Math.log(andereBasis) vorberechnen.</p> + +<h2 id="Beispiele">Beispiele</h2> + +<h3 id="Einsatz_von_Math.log">Einsatz von <code>Math.log()</code></h3> + +<pre class="brush: js notranslate">Math.log(-1); // NaN, weil negativ +Math.log(0); // -Infinity +Math.log(1); // 0 +Math.log(10); // 2.302585092994046 +</pre> + +<h3 id="Einsatz_von_Math.log_mit_unterschiedlichen_Basen">Einsatz von <code>Math.log()</code> mit unterschiedlichen Basen</h3> + +<p>Die folgende Funktion gibt den Logarithmus von <code>y</code> zur Basis <code>x</code> zurück (log<sub>x</sub> y):</p> + +<pre class="brush: js notranslate">function getBaseLog(x, y) { + return Math.log(y) / Math.log(x); +} +</pre> + +<p>Wenn <code>getBaseLog(10, 1000)</code> ausgeführt wird, ist das Ergebnis <code>2.9999999999999996</code>. Diese Zahl ist nah an 3 und kommt durch Rundungsfehler bei Fließkommazahlen.</p> + +<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('ES1')}}</td> + <td>{{Spec2('ES1')}}</td> + <td>Initiale Definition. Implementiert in JavaScript 1.0.</td> + </tr> + <tr> + <td>{{SpecName('ES5.1', '#sec-15.8.2.10', 'Math.log')}}</td> + <td>{{Spec2('ES5.1')}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName('ES6', '#sec-math.log', 'Math.log')}}</td> + <td>{{Spec2('ES6')}}</td> + <td></td> + </tr> + <tr> + <td>{{SpecName('ESDraft', '#sec-math.log', 'Math.log')}}</td> + <td>{{Spec2('ESDraft')}}</td> + <td></td> + </tr> + </tbody> +</table> + +<h2 id="Browserkompatibilität">Browserkompatibilität</h2> + +<p class="hidden">The compatibility table in this page is generated from structured data. If you'd like to contribute to the data, please check out <a href="https://github.com/mdn/browser-compat-data">https://github.com/mdn/browser-compat-data</a> and send us a pull request.</p> + +<p>{{Compat("javascript.builtins.Math.log")}}</p> + +<h2 id="Siehe_auch">Siehe auch</h2> + +<ul> + <li>{{jsxref("Math.exp()")}}</li> + <li>{{jsxref("Math.log1p()")}}</li> + <li>{{jsxref("Math.log10()")}}</li> + <li>{{jsxref("Math.log2()")}}</li> + <li>{{jsxref("Math.pow()")}}</li> +</ul> |
