2026a

# tanh


符号双曲正切函数

函数库: TySymbolicMath

# 语法

tanh(X)

# 说明

tanh(X) 返回 X 的双曲正切函数。 示例

# 示例

绘制双曲正切函数

在从 -π 到 π 的区间上绘制双曲正切函数。

using TySymbolicMath
using TyPlot
@variables x
tanhf = x-> tanh(x)
fplot(tanhf,[-pi pi])
grid("on")
处理包含双曲正切函数的表达式

许多函数,例如 Differential,integrate 和 taylor,可以处理包含双曲正切函数的表达式。

求 tanh 函数的一阶导数和二阶导数:

using TySymbolicMath
@variables x
D = Differential(x)
expand_derivatives(D(tanh(x)))
1 - (tanh(x)^2)
D2 = Differential(x)^2
expand_derivatives(D2(tanh(x)))
-2tanh(x)*(1 - (tanh(x)^2))

求 tanh 函数的不定积分:

TySymbolicMath.integrate(tanh(x))
x - log(1 + tanh(x))

求 tanh 函数的泰勒展开式:

taylor(tanh(x))
┌ Warning: 此函数即将废弃,请使用 taylor_series 函数进行求解。

(x - (1//3)*(x^3) + (2//15)*(x^5), x, 6×2 DataFrame
 Row │ coeffs  order 
     │ Num     Int64
─────┼───────────────
   1 │      0      0
   2 │      1      1
   3 │      0      2
   4 │  -1//3      3
   5 │      0      4
   6 │  2//15      5)

# 输入参数

X - 输入符号
符号变量 | 符号表达式 | 符号函数 | 符号向量 | 符号矩阵

输入符号,指定为符号变量、表达式或函数,或符号变量、表达式或函数的向量或矩阵。

数据类型: Num

# 另请参阅

acosh | asinh | atanh | acsch | asech | acoth | sinh | cosh | csch | sech | coth