ctanf, ctan, ctanl
From cppreference.com
| ヘッダー <complex.h> で定義 |
||
| (1) | (C99以降) | |
| (2) | (C99以降) | |
| (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 が実数または整数である場合、マクロは対応する実数関数 (tanf, tan, tanl) を呼び出します。z が虚数である場合、マクロは関数 tanh の対応する実数バージョンを呼び出し、tan(iy) = i tanh(y) の公式を実装し、戻り値の型は虚数になります。目次 |
[edit] パラメータ
| z | - | 複素数引数 |
[edit] 戻り値
エラーが発生しなかった場合、z の複素数としてのタンジェントが返されます。
エラーおよび特殊ケースは、i を虚数単位として、-i * ctanh(i*z) によって操作が実装されたかのように処理されます。
[edit] 注記
タンジェントは複素平面上の解析関数であり、分岐の切り口を持ちません。実部に対して周期 πi を持ち、実軸に沿って一次の極を持ちます。その座標は (π(1/2 + n), 0) です。しかし、一般的な浮動小数点表現では π/2 を正確に表現できないため、極エラーが発生する引数の値はありません。
タンジェントの数学的定義は tan z =| i(e-iz -eiz ) |
| e-iz +eiz |
[edit] 例
このコードを実行
#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)
[edit] 参考文献
- C11標準 (ISO/IEC 9899:2011)
- 7.3.5.6 The ctan functions (p: 192)
- 7.25 Type-generic complex <tgmath.h> (p: 373-375)
- G.7 Type-generic math <tgmath.h> (p: 545)
- C99標準 (ISO/IEC 9899:1999)
- 7.3.5.6 The ctan functions (p: 174)
- 7.22 Type-generic complex <tgcomplex.h> (p: 335-337)
- G.7 Type-generic math <tgmath.h> (p: 480)
[edit] 関連項目
| (C99)(C99)(C99) |
複素双曲線タンジェントを計算する (関数) |
| (C99)(C99)(C99) |
複素サインを計算する (関数) |
| (C99)(C99)(C99) |
複素コサインを計算する (関数) |
| (C99)(C99)(C99) |
複素アークタンジェントを計算する (関数) |
| (C99)(C99) |
タンジェントを計算する (tan(x)) (関数) |
| C++ ドキュメント (tan)
| |