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。