- C 标准库
- C 库 - 首页
- C 库 - <assert.h>
- C 库 - <complex.h>
- C 库 - <ctype.h>
- C 库 - <errno.h>
- C 库 - <fenv.h>
- C 库 - <float.h>
- C 库 - <inttypes.h>
- C 库 - <iso646.h>
- C 库 - <limits.h>
- C 库 - <locale.h>
- C 库 - <math.h>
- C 库 - <setjmp.h>
- C 库 - <signal.h>
- C 库 - <stdalign.h>
- C 库 - <stdarg.h>
- C 库 - <stdbool.h>
- C 库 - <stddef.h>
- C 库 - <stdio.h>
- C 库 - <stdlib.h>
- C 库 - <string.h>
- C 库 - <tgmath.h>
- C 库 - <time.h>
- C 库 - <wctype.h>
- C 标准库资源
- C 库 - 快速指南
- C 库 - 有用资源
- C 库 - 讨论
C 库 - catanh() 函数
C 的complex 库 catanh() 函数用于计算复数的反双曲正切,即 z 的反双曲正切,其分支切割位于实轴上的区间 [−1,+1] 之外。它使函数对于任何不位于实轴此区间上的复数 z 连续且单值。
The arc hyperbolic tangent (atanh) z is defined as: atanh(z) = 1/2ln(1+z/1-z)
此函数取决于 z 的类型。如果 z 是“float”类型,我们使用catanhf()计算反双曲正切,对于长双精度类型,使用catanhl(),对于双精度类型,使用catanh()。
语法
以下是 catanh() 函数的 C 库语法 -
double complex catanh( double complex z );
参数
此函数接受一个参数 -
-
Z - 它表示我们要计算 atanh 的复数。
返回值
此函数返回 z 的复数反(弧)双曲正切,在沿实轴无界的半带内,虚轴始终位于 [−iπ/2, +iπ/2] 之间。
示例 1
以下是一个基本的 c 程序,用于演示在复数上使用 catanh()。
#include <stdio.h>
#include <complex.h>
#include <math.h>
int main() {
// Define z
double complex z = 0.5 + 0.5*I;
// Calculate the complex inverse hyperbolic tangent of z
double complex res= catanh(z);
// Display the result
printf("catanh(%.2f + %.2fi) = %.2f + %.2fi\n", creal(z), cimag(z), creal(res), cimag(res));
return 0;
}
输出
以下是输出 -
catanh(0.50 + 0.50i) = 0.40 + 0.55i
示例 2
让我们看另一个示例,使用 catanh() 函数计算实轴的反双曲正切。
#include <stdio.h>
#include <math.h>
#include <complex.h>
int main(void)
{
// real axis
double complex z = catanh(1);
printf("tanh(1+0i) = %.2f+%.2fi \n", creal(z), cimag(z));
}
输出
以下是输出 -
tanh(1+0i) = inf+0.00i
示例 3
下面的程序计算复数的虚线的反双曲正切 (atanh) 和双曲正切 (tanh),然后比较答案以查看它们是否相同。
#include <complex.h>
#include <stdio.h>
#include <math.h>
int main() {
double complex z = 0.0 + 1.0*I;
double complex atanh = catanh(z);
double complex tanh = ctanh(z);
printf("catanh(%.1fi) = %.2f + %.2fi\n", cimag(z), creal(atanh), cimag(atanh));
printf("ctanh(%.1fi) = %.2f + %.2fi\n", cimag(z), creal(tanh), cimag(tanh));
if (cabs(atanh) == cabs(tanh)) {
printf("The arc hyperbolic tangent and hyperbolic tangent of the imaginary line are approximately the same.\n");
} else {
printf("The arc hyperbolic tangent and hyperbolic tangent of the imaginary line are different.\n");
}
return 0;
}
输出
以下是输出 -
catanh(1.0i) = 0.00 + 1.56i ctan(1.0i) = 0.00 + 0.76i The hyperbolic tangent and tangent of the imaginary line are different.
c_library_complex_h.htm
广告