Math.tanh()

Math.tanh() 静态方法返回数字的双曲正切。那是,

¥The Math.tanh() static method returns the hyperbolic tangent of a number. That is,

𝙼𝚊𝚝𝚑.𝚝𝚊𝚗𝚑 ( 𝚡 ) = tanh ( x ) = sinh ( x ) cosh ( x ) = e x e x e x + e x = e 2 x 1 e 2 x + 1 \mathtt{\operatorname{Math.tanh}(x)} = \tanh(x) = \frac{\sinh(x)}{\cosh(x)} = \frac{\mathrm{e}^x - \mathrm{e}^{-x}}{\mathrm{e}^x + \mathrm{e}^{-x}} = \frac{\mathrm{e}^{2x} - 1}{\mathrm{e}^{2x}+1}

Try it

语法

¥Syntax

js
Math.tanh(x)

参数

¥Parameters

x

一个号码。

返回值

¥Return value

x 的双曲正切。

¥The hyperbolic tangent of x.

描述

¥Description

因为 tanh()Math 的静态方法,所以你始终将其用作 Math.tanh(),而不是用作你创建的 Math 对象的方法(Math 不是构造函数)。

¥Because tanh() is a static method of Math, you always use it as Math.tanh(), rather than as a method of a Math object you created (Math is not a constructor).

示例

¥Examples

使用 Math.tanh()

¥Using Math.tanh()

js
Math.tanh(-Infinity); // -1
Math.tanh(-0); // -0
Math.tanh(0); // 0
Math.tanh(1); // 0.7615941559557649
Math.tanh(Infinity); // 1

规范

Specification
ECMAScript Language Specification
# sec-math.tanh

¥Specifications

浏览器兼容性

BCD tables only load in the browser

¥Browser compatibility

也可以看看