名稱空間
變體
操作

ctanf, ctan, ctanl

來自 cppreference.com
< c‎ | 數值‎ | 複數
定義在標頭檔案 <complex.h>
float complex       ctanf( float complex z );
(1) (C99 起)
double complex      ctan( double complex z );
(2) (C99 起)
long double complex ctanl( long double complex z );
(3) (C99 起)
定義於標頭檔案 <tgmath.h>
#define tan( z )
(4) (C99 起)
1-3) 計算 z 的複數正切。
4) 型別泛型宏:如果 z 的型別為 long double complex,則呼叫 ctanl。如果 z 的型別為 double complex,則呼叫 ctan。如果 z 的型別為 float complex,則呼叫 ctanf。如果 z 是實數或整數,則宏呼叫對應的實數函式(tanftantanl)。如果 z 是虛數,則宏呼叫函式 tanh 的相應實數版本,實現公式 tan(iy) = i tanh(y),並且返回型別為虛數。

目錄

[編輯] 引數

z - 複數引數

[編輯] 返回值

如果未發生錯誤,則返回 z 的複數正切。

錯誤和特殊情況的處理方式如同操作透過 -i * ctanh(i*z) 實現,其中 i 是虛數單位。

[編輯] 注意

正切是複平面上的解析函式,沒有分支切割。它相對於實部週期性地變化,週期為 πi,並且沿實線在座標 (π(1/2 + n), 0) 處具有一階極點。但是,沒有常見的浮點表示能夠精確表示 π/2,因此不存在導致極點錯誤的引數值。

正切的數學定義是 tan z =
i(e-iz
-eiz
)
e-iz
+eiz

[編輯] 示例

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

輸出

tan(1+0i) = 1.557408+0.000000i ( tan(1)=1.557408)
tan(0+1i) = 0.000000+0.761594i (tanh(1)=0.761594)

[編輯] 參考

  • C11 標準 (ISO/IEC 9899:2011)
  • 7.3.5.6 ctan 函式 (p: 192)
  • 7.25 型別泛型複數 <tgmath.h> (p: 373-375)
  • G.7 型別通用數學 <tgmath.h> (p: 545)
  • C99 標準 (ISO/IEC 9899:1999)
  • 7.3.5.6 ctan 函式 (p: 174)
  • 7.22 型別泛型複數 <tgcomplex.h> (p: 335-337)
  • G.7 型別通用數學 <tgmath.h> (p: 480)

[編輯] 另請參閱

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