C语言tanh()函数:双曲线正切函数
头文件:#include <math.h>
tanh() 用来求一个数的双曲正切值,其原型为:
double tanh(double x);
【参数】x 为双曲正切上的某点。
【返回值】返回 x 的双曲正切值,取值范围为 -1 到 1。
双曲正切的定义为 sinh(x)/cosh(x),即

双曲正切曲线示意图:

注意,使用 GCC 编译时请加入-lm。
请看下面的代码:
tanh(0.5) = 0.462117
tanh() 用来求一个数的双曲正切值,其原型为:
double tanh(double x);
【参数】x 为双曲正切上的某点。
【返回值】返回 x 的双曲正切值,取值范围为 -1 到 1。
双曲正切的定义为 sinh(x)/cosh(x),即

双曲正切曲线示意图:

注意,使用 GCC 编译时请加入-lm。
请看下面的代码:
#include <math.h> main(){ double answer = tanh(0.5); printf("tanh(0.5) = %f\n", answer); }输出结果:
tanh(0.5) = 0.462117