C庫 - csinh() 函式



C語言的complex庫中的csinh()函式用於計算z(複數)的雙曲正弦值。雙曲正弦函式的性質與普通正弦函式類似,不同之處在於它與雙曲線而不是圓有關。

The hyperbolic sine (sinh) complex number (z) is defined as:
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;

   // Calculate the sinh
   double complex res = csinh(z);
   printf("Complex sinh: %.2f%+.2fi\n", 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)
{
    // real line
    double complex z = csinh(1);
    printf("sinh(1+0i) = %f+%fi (sinh(1)=%f)\n", 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)
{
   // imaginary line
   double complex z2 = csinh(I); 
   printf("sinh(0+1i) = %f+%fi ( sin(1)=%f)\n", creal(z2), cimag(z2), sin(1));
}

輸出

以下是輸出:

sinh(0+1i) = 0.000000+0.841471i ( sin(1)=0.841471)
c_library_complex_h.htm
廣告
© . All rights reserved.