--- title: Math.cosh() slug: Web/JavaScript/Reference/Global_Objects/Math/cosh tags: - JavaScript - Math - Method - Reference translation_of: Web/JavaScript/Reference/Global_Objects/Math/cosh ---
Math.cosh() 関数は、引数として与えた数の双曲線余弦 (ハイパーボリックコサイン) を返します。これは{{jsxref("Math.E", "定数 e", "", 1)}} を使用して次のように表すことができます。
Math.cosh(x)
x指定された数値の双曲線余弦 (ハイパーボリックコサイン) です。
cosh() は Math の静的メソッドであるため、生成した Math オブジェクトのメソッドとしてではなく、常に Math.cosh() として使用するようにしてください (Math はコンストラクターではありません)。
Math.cosh(0); // 1 Math.cosh(1); // 1.5430806348152437 Math.cosh(-1); // 1.5430806348152437
これは {{jsxref("Math.exp()")}} 関数を使用して次のようにエミュレートできます。
Math.cosh = Math.cosh || function(x) {
return (Math.exp(x) + Math.exp(-x)) / 2;
}
または {{jsxref("Math.exp()")}} 関数を一度だけ呼び出すようにすると、次のようになります。
Math.cosh = Math.cosh || function(x) {
var y = Math.exp(x);
return (y + 1 / y) / 2;
};
| 仕様書 |
|---|
| {{SpecName('ESDraft', '#sec-math.cosh', 'Math.cosh')}} |
{{Compat("javascript.builtins.Math.cosh")}}