tanh (Numerics) – C 中文开发手册
tanh (Numerics) - C 中文开发手册
在头文件<math.h>中定义 | | |
---|---|---|
float tanhf(float arg); | (1) | (自C99以来) |
double tanh(double arg); | (2) | |
long double tanhl(long double arg); | (3) | (自C99以来) |
在头文件<tgmath.h>中定义 | | |
#define tanh(arg) | (4) | (自C99以来) |
1-3)计算arg的双曲正切。4)类型 - 泛型宏:如果参数的类型为long double,则调用tanhl。 否则,如果参数具有整数类型或类型double,则调用tanh。 否则,调用tanhf。 如果参数很复杂,那么宏调用相应的复合函数(ctanhf,ctanh,ctanhl)。
参数
arg | - | floating point value representing a hyperbolic angle |
---|
返回值
如果没有错误发生,则返回arg(tanh(arg)或者双曲正切| earg-e-arg ||:----|| earg+e-arg |)被返回。 如果由于下溢而发生范围错误,则返回正确的结果(舍入后)。
错误处理
按照math_errhandling中的指定报告错误。如果实现支持IEEE浮点运算(IEC 60559),如果参数为±0,则返回±0 如果参数为±∞,则返回±1 如果参数是NaN,则返回NaN
注意
POSIX指定在发生下溢时,arg未经修改就返回,如果不支持,则返回不大于DBL_MIN,FLT_MIN和LDBL_MIN的实现定义值。
例
#include <stdio.h> #include <math.h> int main(void) { printf("tanh(1) = %f\ntanh(-1) = %f\n", tanh(1), tanh(-1)); printf("tanh(0.1)*sinh(0.2)-cosh(0.2) = %f\n", tanh(0.1) * sinh(0.2) - cosh(0.2)); // special values printf("tanh(+0) = %f\ntanh(-0) = %f\n", tanh(0.0), tanh(-0.0)); }
输出:
tanh(1) = 0.761594 tanh(-1) = -0.761594 tanh(0.1)*sinh(0.2)-cosh(0.2) = -1.000000 tanh(+0) = 0.000000 tanh(-0) = -0.000000
参考
C11标准(ISO / IEC 9899:2011): 7.12.5.6 tanh函数(p:242) 7.25类型通用数学<tgmath.h>(p:373-375) F.10.2.6 tanh函数(p:520) C99标准(ISO / IEC 9899:1999): 7.12.5.6 tanh函数(p:222-223) 7.22类型通用数学<tgmath.h>(p:335-337) F.9.2.6 tanh函数(p:457) C89 / C90标准(ISO / IEC 9899:1990): 4.5.3.3 tanh函数
扩展内容
sinhsinhfsinhl(C99)(C99) | 计算双曲正弦函数(sh(x))(函数) |
---|---|
coshcoshfcoshl(C99)(C99) | 计算双曲余弦(ch(x))(函数) |
atanhatanhfatanhl(C99)(C99)(C99) | 计算反双曲正切(artanh(x))(函数) |
(C99)(C99)(C99) | 计算复数双曲正切(函数) |
|tanh的 C ++文档 |
C 语言中文开发手册