C 库 - csinh() 函数
C complex 库中的 csinh() 函数用于计算 z(复数)的双曲sinh函数。双曲正弦函数的性质与常规正弦函数相似,只是它与双曲线相关,而不是圆。
复数 (z) 的双曲正弦 (sinh) 定义为: sinh(z)= ez - e-z/2
此函数取决于 z(复数)的类型。如果 z 是"float"类型,我们使用 csinhf() 来计算 sinh;对于 long double 类型,使用 csinhl();对于 double 类型,使用 csinh()。
语法
以下是 csinh() 函数的 C 库语法 -
double complex csinh( double complex z );
参数
此函数接受单个参数 -
-
Z - 它表示一个复数,我们需要计算其 sinh 值。
返回值
此函数返回 z(复数)的复数双曲正弦值。
示例 1
以下是一个基本的 C 程序,用于演示如何对复数使用 csinh()。
#include <stdio.h>
#include <complex.h>
int main() {
double complex z = 3.0 + 4.0 * I;
// 计算 sinh
double complex res = csinh(z);
printf("Complex sinh: %.2f%+.2fi", creal(res), cimag(res));
return 0;
}
输出
以下是输出 -
Complex sinh: -6.55-7.62i
示例 2
我们来看另一个示例,使用 csinh() 函数计算实数的双曲正弦。
#include <stdio.h>
#include <math.h>
#include <complex.h>
int main(void)
{
// 实线
double complex z = csinh(1);
printf("sinh(1+0i) = %f+%fi (sinh(1)=%f)", creal(z), cimag(z), sinh(1));
}
输出
以下是输出 -
Square root of -4 is 0.0+2.0i
示例 3
以下程序使用 csinh() 函数计算虚线的双曲正弦值。
#include <stdio.h>
#include <math.h>
#include <complex.h>
int main(void)
{
// 假想线
double complex z2 = csinh(I);
printf("sinh(0+1i) = %f+%fi ( sin(1)=%f)", creal(z2), cimag(z2), sin(1));
}
输出
以下是输出 -
sinh(0+1i) = 0.000000+0.841471i ( sin(1)=0.841471)

