Math.atanh()
Math.atanh() 関数は、数値の双曲線逆正接 (ハイパーボリックアークタンジェント) を返します。
試してみましょう
構文
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 が返されます。
ポリフィル
に対して、 になり、次の関数でエミュレートできます。
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