名稱空間
變體
操作

ccosf, ccos, ccosl

來自 cppreference.com
< c‎ | numeric‎ | complex
定義在標頭檔案 <complex.h>
float complex       ccosf( float complex z );
(1) (C99 起)
double complex      ccos( double complex z );
(2) (C99 起)
long double complex ccosl( long double complex z );
(3) (C99 起)
定義於標頭檔案 <tgmath.h>
#define cos( z )
(4) (C99 起)
1-3) 計算 z 的複數餘弦。
4) 型別泛型宏:若 z 的型別為 long double complex,則呼叫 ccosl。若 z 的型別為 double complex,則呼叫 ccos。若 z 的型別為 float complex,則呼叫 ccosf。若 z 為實數或整數,則宏呼叫對應的實函式(cosfcoscosl)。若 z 為虛數,則宏呼叫函式 cosh 的對應實數版本,實現公式 cos(iy) = cosh(y),且返回型別為實數。

目錄

[編輯] 引數

z - 複數引數

[編輯] 返回值

若無錯誤發生,則返回 z 的複數餘弦。

錯誤和特殊情況的處理方式,如同操作是透過 ccosh(I*z) 實現的。

[編輯] 注意

餘弦是複平面上的整函式,沒有分支切割。

餘弦的數學定義是 cos z =
eiz
+e-iz
2

[編輯] 示例

#include <stdio.h>
#include <math.h>
#include <complex.h>
 
int main(void)
{
    double complex z = ccos(1);  // behaves like real cosine along the real line
    printf("cos(1+0i) = %f%+fi ( cos(1)=%f)\n", creal(z), cimag(z), cos(1));
 
    double complex z2 = ccos(I); // behaves like real cosh along the imaginary line
    printf("cos(0+1i) = %f%+fi (cosh(1)=%f)\n", creal(z2), cimag(z2), cosh(1));
}

輸出

cos(1+0i) = 0.540302-0.000000i ( cos(1)=0.540302)
cos(0+1i) = 1.543081-0.000000i (cosh(1)=1.543081)

[編輯] 參考

  • C11 標準 (ISO/IEC 9899:2011)
  • 7.3.5.4 ccos 函式 (p: 191)
  • 7.25 型別通用數學 <tgmath.h> (p: 373-375)
  • G.7 型別通用數學 <tgmath.h> (p: 545)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.3.5.4 ccos 函式 (p: 173)
  • 7.22 型別通用數學 <tgmath.h> (p: 335-337)
  • G.7 型別通用數學 <tgmath.h> (p: 480)

[編輯] 參閱

(C99)(C99)(C99)
計算復正弦
(函式) [編輯]
(C99)(C99)(C99)
計算復正切
(函式) [編輯]
(C99)(C99)(C99)
計算復反餘弦
(函式) [編輯]
(C99)(C99)
計算餘弦 (cos(x))
(函式) [編輯]
C++ 文件 for cos