Math.acosh()返回一个数字的反双曲余弦值,即:

x1,Math.acosh(x)=arcosh(x)= the unique y0such thatcosh(y)=x\forall x \geq 1, \mathtt{\operatorname{Math.acosh}(x)} = \operatorname{arcosh}(x) = \text{ the unique } \; y \geq 0 \; \text{such that} \; \cosh(y) = x

语法

Math.acosh(x)

参数

x
一个数字。

返回值

返回指定参数的反双曲余弦值,如果指定的参数小于 1 则返回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()将返回 NaN

替代方案

当 x1 时,都有 arcosh(x)=ln(x+x2-1)\operatorname {arcosh} (x) = \ln \left(x + \sqrt{x^{2} - 1} \right) ,因此我们可以使用以下函数来模仿Math.acosh():

Math.acosh = Math.acosh || function(x) {
  return Math.log(x + Math.sqrt(x * x - 1));
};

规范

版本 状态 注释
ECMAScript 2015 (6th Edition, ECMA-262)
Math.acosh
Standard Initial definition.
ECMAScript Latest Draft (ECMA-262)
Math.acosh
Draft  

浏览器兼容性

We're converting our compatibility data into a machine-readable JSON format. This compatibility table still uses the old format, because we haven't yet converted the data it contains. Find out how you can help!
Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support 38 25 (25) 未实现 25 7.1
Feature Android Chrome for Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support 未实现 未实现 25.0 (25) 未实现 未实现 8

相关链接