Math.acosh()

Baseline 已广泛支持

此特性已相当成熟,可在许多设备和浏览器版本上使用。自 ⁨2015 年 7 月⁩以来,各浏览器均已提供此特性。

Math.acosh() 静态方法返回一个数字的逆双曲余弦值。也就是说,

x1,𝙼𝚊𝚝𝚑.𝚊𝚌𝚘𝚜𝚑(𝚡)=arcosh(x)=唯一y0使得cosh(y)=x=ln(x+x21)\begin{aligned}\forall x \geq 1,\;\mathtt{\operatorname{Math.acosh}(x)} &= \operatorname{arcosh}(x) = \text{ the unique } y \geq 0 \text{ such that } \cosh(y) = x\\&= \ln\left(x + \sqrt{x^2 - 1}\right)\end{aligned}

试一试

console.log(Math.acosh(0.999999999999));
// Expected output: NaN

console.log(Math.acosh(1));
// Expected output: 0

console.log(Math.acosh(2));
// Expected output: 1.3169578969248166

console.log(Math.acosh(2.5));
// Expected output: 1.566799236972411

语法

js
Math.acosh(x)

参数

x

大于或等于 1 的数字。

返回值

x 的逆双曲余弦值。如果 x 小于 1,则返回 NaN

描述

因为 acosh()Math 的一个静态方法,所以你总是使用 Math.acosh() 来调用它,而不是作为你创建的 Math 对象的成员方法(Math 不是一个构造函数)。

示例

使用 Math.acosh()

js
Math.acosh(0); // NaN
Math.acosh(1); // 0
Math.acosh(2); // 1.3169578969248166
Math.acosh(Infinity); // Infinity

规范

规范
ECMAScript® 2026 语言规范
# sec-math.acosh

浏览器兼容性

另见