aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/javascript/reference/global_objects/math/atanh/index.html
blob: fe00a1eba203fcd67e5674261eda13ab0f293fb9 (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
---
title: Math.atanh()
slug: Web/JavaScript/Reference/Global_Objects/Math/atanh
translation_of: Web/JavaScript/Reference/Global_Objects/Math/atanh
---
<div>{{JSRef}}</div>

<p><strong><code>Math.atanh()</code></strong> 函数返回一个数值反双曲正切值, 即:</p>

<p><math display="block"><semantics><mrow><mo></mo><mi>x</mi><mo></mo><mrow><mo>(</mo><mrow><mo>-</mo><mn>1</mn><mo>,</mo><mn>1</mn></mrow><mo>)</mo></mrow><mo>,</mo><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.atanh</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="thinmathspace">arctanh</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mtext> the unique </mtext><mspace width="thickmathspace"></mspace><mi>y</mi><mspace width="thickmathspace"></mspace><mtext>such that</mtext><mspace width="thickmathspace"></mspace><mo lspace="0em" rspace="0em">tanh</mo><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } \; y \; \text{such that} \; \tanh(y) = x</annotation></semantics></math></p>

<h2 id="语法">语法</h2>

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

<h3 id="参数">参数</h3>

<dl>
 <dt><code>x</code></dt>
 <dd>一个数值</dd>
</dl>

<h2 id="描述">描述</h2>

<p>由于 <code>atanh()</code> 是 <code>Math 的静态方法</code>,所以应该像这样使用:<code>Math.atanh()</code>,而不是作为你创建的 <code>Math</code> 实例的方法(<code>Math 不是一个构造函数</code>)。 </p>

<h2 id="示例">示例</h2>

<h3 id="使用_Math.atanh()"><code>使用 Math.atanh()</code></h3>

<pre class="brush: js">Math.atanh(-2);  // NaN
Math.atanh(-1);  // -Infinity
Math.atanh(0);   // 0
Math.atanh(0.5); // 0.5493061443340548
Math.atanh(1);   // Infinity
Math.atanh(2);   // NaN
</pre>

<p>对于大于1或是小于-1的值,函数返回 {{jsxref("NaN")}}</p>

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

<p>For \left|x\right| &lt; 1, we have \operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right) so this can be emulated by the following function:</p>

<pre class="brush: js">Math.atanh = Math.atanh || function(x) {
  return Math.log((1+x)/(1-x)) / 2;
};
</pre>

<h2 id="规范">规范</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('ES6', '#sec-math.atanh', 'Math.atanh')}}</td>
   <td>{{Spec2('ES6')}}</td>
   <td>Initial definition.</td>
  </tr>
  <tr>
   <td>{{SpecName('ESDraft', '#sec-math.atanh', 'Math.atanh')}}</td>
   <td>{{Spec2('ESDraft')}}</td>
   <td> </td>
  </tr>
 </tbody>
</table>

<h2 id="浏览器兼容性">浏览器兼容性</h2>

{{Compat}}

<h2 id="相关链接">相关链接</h2>

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