C 标准库 - <math.h>

C 语言 tanh() 函数用于计算一个数的双曲正切值:tanh(x) = sinh(x) / cosh(x)。

原型

double tanh(double x);

参数

  • x - 要求双曲正切的值(double)。

示例

#include <stdio.h>
#include <math.h>

int main() {
    printf("tanh(1) = %.4f\n", tanh(1));
    return 0;
}

输出:

tanh(1) = 0.7616

注意事项

使用 math.h 的函数时,多数编译器需要链接数学库(编译选项 -lm)。