C
数值 | Numerics

tanhf

tanh, tanhf, tanhl

在头文件中定义
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-浮点值代表双曲线角度

返回值

如果没有错误发生,arg(tanh(arg)或者双曲正切

| earg-e-arg |

|:----|

| earg+e-arg |

)被返回。

如果由于下溢而发生范围错误,则返回正确的结果(舍入后)。

错误处理

按照math_errhandling中的指定报告错误。

如果实现支持IEEE浮点运算(IEC 60559),

  • 如果参数为±0,则返回±0

注意

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):

扩展内容

sinhsinhfsinhl(C99)(C99)计算双曲正弦函数(sh(x))(函数)
coshcoshfcoshl(C99)(C99)计算双曲余弦(ch(x))(函数)
atanhatanhfatanhl(C99)(C99)(C99)计算反双曲正切(artanh(x))(函数)
(C99)(C99)(C99)计算复数双曲正切(函数)

| tanh的C ++文档 |