JavaScript Math.asinh() 方法
JavaScript 中的 Math.asinh() 方法用于计算一个数的反双曲正弦值(也称为 arcsinh)。从数学上讲,它计算值"y",即 sinh(y) = x,其中 x 是输入值。结果以弧度表示。
反双曲正弦函数的公式为 −
asinh(x) = ln(x + √(x^2 + 1))
其中,"x" 表示我们要求其反双曲正弦值的输入值。
语法
以下是 JavaScript Math.asinh() 方法的语法 −
Math.asinh(x)
参数
此方法仅接受一个参数。下文同样描述 -
- x: 一个数值。
返回值
此方法返回给定数字的双曲反正弦值。
示例 1
在下面的示例中,我们使用 JavaScript Math.asinh() 方法返回 1 和 -1 的反双曲正弦值 -
<html> <body> <script> const result1 = Math.asinh(1); const result2 = Math.asinh(-1); document.write(result1, "<br>", result2); </script> </body> </html>
输出
执行上述程序,将返回 0.8813 和 -0.8813。
示例 2
这里,我们计算 0 和 -0 的反双曲正弦值 −
<html> <body> <script> const result1 = Math.asinh(0); const result2 = Math.asinh(-0); document.write(result1, "<br>", result2); </script> </body> </html>
输出
如果执行程序,它将返回 0。
示例 3
如果我们提供 Infinity 和 -Infinity 作为参数,它将分别返回 Infinity 和 -Infinity -
<html> <body> <script> const result1 = Math.asinh(Infinity); const result2 = Math.asinh(-Infinity); document.write(result1, "<br>", result2); </script> </body> </html>
输出
程序执行后,分别返回 Infinity 和 -Infinity。

