Math.atanh()

Math.atanh() 関数は、数値の双曲線逆正接 (ハイパーボリックアークタンジェント) を返します。

x ( - 1 , 1 ) , Math.atanh ( x ) = arctanh ( x ) = the unique y such that tanh ( y ) = x \forall x \in \left( -1, 1 \right), \mathtt{\operatorname{Math.atanh}(x)} = \operatorname{arctanh}(x) = \text{ the unique } ; y ; \text{such that} ; \tanh(y) = x

試してみましょう

構文

Math.atanh(x)

引数

x

数値。

返値

与えられた数値の双曲線逆正接 (ハイパーボリックアークタンジェント) です。

解説

atanh()Math の静的メソッドであるため、生成した Math オブジェクトのメソッドとしてではなく、常に Math.atanh() として使用するようにしてください (Math はコンストラクターではありません)。

Math.atanh() の使用

js
Math.atanh(-2); // NaN
Math.atanh(-1); // -Infinity
Math.atanh(0); // 0
Math.atanh(0.5); // 0.5493061443340548
Math.atanh(1); // Infinity
Math.atanh(2); // NaN

1よりも大きな値もしくは -1 よりも小さな値に対しては、 NaN が返されます。

ポリフィル

| x | < 1 \left|x\right| < 1 に対して、 artanh ( x ) = 1 2 ln ( 1 + x 1 - x ) \operatorname {artanh} (x) = \frac{1}{2}\ln \left( \frac{1 + x}{1 - x} \right) になり、次の関数でエミュレートできます。

js
Math.atanh =
  Math.atanh ||
  function (x) {
    return Math.log((1 + x) / (1 - x)) / 2;
  };

仕様書

Specification
ECMAScript Language Specification
# sec-math.atanh

ブラウザーの互換性

BCD tables only load in the browser

関連情報