--- title: Math.acosh() slug: Web/JavaScript/Reference/Global_Objects/Math/acosh tags: - JavaScript - 双曲函数 - 数学 - 方法 translation_of: Web/JavaScript/Reference/Global_Objects/Math/acosh original_slug: Web/JavaScript/Reference/Global_Objects/Math/反双曲余弦值 ---
Math.acosh() 函数返回一个数的反双曲余弦值,即:
Math.acosh(x)
x返回给定数的反双曲余弦值,如果该数小于 1 则返回 {{jsxref("NaN")}}。
因为 acosh() 是 Math 的静态方法,所以总应该直接调用 Math.acosh() ,而不是创建 Math 对象再调用该方法(Math 不是一个构造函数)。
Math.acosh()Math.acosh(-1); // NaN Math.acosh(0); // NaN Math.acosh(0.5); // NaN Math.acosh(1); // 0 Math.acosh(2); // 1.3169578969248166
当参数小于1时, Math.acosh()将返回 {{jsxref("NaN")}}。
当 时,都有 ,因此可以使用以下函数实现:
Math.acosh = Math.acosh || function(x) {
return Math.log(x + Math.sqrt(x * x - 1));
};
| Specification |
|---|
| {{SpecName('ESDraft', '#sec-math.acosh', 'Math.acosh')}} |
{{Compat("javascript.builtins.Math.acosh")}}