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

瀏覽器相容性

另見