blob: 1c8686ae416006f1b7ee39bde6bd95981fe8089f (
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
|
---
title: Math.asinh()
slug: Web/JavaScript/Reference/Global_Objects/Math/asinh
translation_of: Web/JavaScript/Reference/Global_Objects/Math/asinh
---
<div>{{JSRef}}</div>
<p><strong><code>Math.asinh()</code></strong> 返回一个数值的反双曲正弦值,即:</p>
<p><math display="block"><semantics><mrow><mstyle mathvariant="monospace"><mrow><mo lspace="0em" rspace="thinmathspace">Math.asinh</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle><mo>=</mo><mo lspace="0em" rspace="thinmathspace">arsinh</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">sinh</mo><mo stretchy="false">(</mo><mi>y</mi><mo stretchy="false">)</mo><mo>=</mo><mi>x</mi></mrow><annotation encoding="TeX">\mathtt{\operatorname{Math.asinh}(x)} = \operatorname{arsinh}(x) = \text{ the unique } \; y \; \text{such that} \; \sinh(y) = x</annotation></semantics></math></p>
<div>{{EmbedInteractiveExample("pages/js/math-asinh.html")}}</div>
<h2 id="语法">语法</h2>
<pre class="syntaxbox"><code>Math.asinh(<var>x</var>)</code></pre>
<h3 id="参数">参数</h3>
<dl>
<dt><code>x</code></dt>
<dd>一个数值.</dd>
</dl>
<h3 id="返回值">返回值</h3>
<p>返回指定数值的反双曲正弦值.</p>
<h2 id="描述">描述</h2>
<p>由于 <code>asinh()</code> 是 <code>Math 的静态方法</code>,所以应该像这样使用:<code>Math.asinh()</code>,而不是作为你创建的 <code>Math</code> 实例的方法(<code>Math 不是一个构造函数</code>)。</p>
<h2 id="示例">示例</h2>
<h3 id="使用_Math.asinh"> 使用 <code>Math.asinh()</code></h3>
<pre class="brush: js">Math.asinh(1); // 0.881373587019543
Math.asinh(0); // 0
</pre>
<h2 id="Polyfill">Polyfill</h2>
<p>As a quick and dirty hack the expression <math><semantics><mrow><mo lspace="0em" rspace="thinmathspace">arsinh</mo><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mo>=</mo><mo lspace="0em" rspace="0em">ln</mo><mrow><mo>(</mo><mrow><mi>x</mi><mo>+</mo><msqrt><mrow><msup><mi>x</mi><mn>2</mn></msup><mo>+</mo><mn>1</mn></mrow></msqrt></mrow><mo>)</mo></mrow></mrow><annotation encoding="TeX">\operatorname {arsinh} (x) = \ln \left(x + \sqrt{x^{2} + 1} \right)</annotation></semantics></math> may be used directly for a coarse emulation by the following function:</p>
<pre class="brush: js">Math.asinh = Math.asinh || function(x) {
if (x === -Infinity) {
return x;
} else {
return Math.log(x + Math.sqrt(x * x + 1));
}
};
</pre>
<p>Been formally correct it suffers from a number of issues related to floating point computations. Accurate result requires special handling of positive/negative, small/large arguments as it done e.g. in <a href="https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/ieee754/dbl-64/s_asinh.c">glibc</a> or <a href="http://git.savannah.gnu.org/cgit/gsl.git/tree/sys/invhyp.c">GNU Scientific Library</a>.</p>
<h2 id="规范">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
</tr>
</thead>
<tbody>
<tr>
<td>{{SpecName('ESDraft', '#sec-math.asinh', 'Math.asinh')}}</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("javascript.builtins.Math.asinh")}}</p>
<h2 id="相关链接">相关链接</h2>
<ul>
<li>{{jsxref("Math.acosh()")}}</li>
<li>{{jsxref("Math.atanh()")}}</li>
<li>{{jsxref("Math.cosh()")}}</li>
<li>{{jsxref("Math.sinh()")}}</li>
<li>{{jsxref("Math.tanh()")}}</li>
</ul>
|