名前空間
変種
操作

clogf, clog, clogl

提供: cppreference.com
< c‎ | numeric‎ | complex
ヘッダ <complex.h> で定義
float complex       clogf( float complex z );
(1) (C99以上)
double complex      clog( double complex z );
(2) (C99以上)
long double complex clogl( long double complex z );
(3) (C99以上)
ヘッダ <tgmath.h> で定義
#define log( z )
(4) (C99以上)
1-3) 負の実軸に沿った分岐切断を持つ、 (e を底とする) z の複素自然対数を計算します。
4) 型総称マクロ。 zlong double complex の場合は clogl が呼ばれ、 zdouble complex 型の場合は clog が呼ばれ、 zfloat complex 型の場合は clogf が呼ばれます。 z が実数または整数の場合は、このマクロは対応する実数の関数 (logfloglogl) を呼びます。 z が虚数の場合は、対応する複素数版が呼ばれます。

目次

[編集] 引数

z - 複素数の引数

[編集] 戻り値

エラーが発生しなければ、 z の複素自然対数が返されます。 戻り値は実部が数学的に非有界で虚部が区間 [−iπ, +iπ] 内の帯状の範囲内になります。

[編集] エラー処理および特殊な値

エラーは math_errhandling と一貫性があるように報告されます。

処理系が IEEE 浮動小数点算術をサポートしている場合、

  • この関数は虚部の符号を考慮すれば分岐切断上で連続的です。
  • clog(conj(z)) == conj(clog(z)) です。
  • z-0+0i であれば、結果は -∞+πi であり、 FE_DIVBYZERO が発生します。
  • z+0+0i であれば、結果は -∞+0i であり、 FE_DIVBYZERO が発生します。
  • zx+∞i (ただし x は任意の有限な値) であれば、結果は +∞+πi/2 です。
  • zx+NaNi (ただし x は任意の有限な値) であれば、結果は NaN+NaNi であり、 FE_INVALID が発生するかもしれません。
  • z-∞+yi (ただし y は任意の有限な正の値) であれば、結果は +∞+πi です。
  • z+∞+yi (ただし y は任意の有限な正の値) であれば、結果は +∞+0i です。
  • z-∞+∞i であれば、結果は +∞+3πi/4 です。
  • z+∞+∞i であれば、結果は +∞+πi/4 です。
  • z±∞+NaNi であれば、結果は +∞+NaNi です。
  • zNaN+yi (ただし y は任意の有限な値) であれば、結果は NaN+NaNi であり、 FE_INVALID が発生するかもしれません。
  • zNaN+∞i であれば、結果は +∞+NaNi です。
  • zNaN+NaNi であれば、結果は NaN+NaNi です。

[編集] ノート

極座標 (r,θ) を持つ複素数 z の自然対数は、 ln r + i(θ+2nπ) と等しくなります。 主値は ln r + iθ です。

[編集]

#include <stdio.h>
#include <math.h>
#include <complex.h>
 
int main(void)
{
    double complex z = clog(I); // r = 1, θ = pi/2
    printf("2*log(i) = %.1f%+fi\n", creal(2*z), cimag(2*z));
 
    double complex z2 = clog(sqrt(2)/2 + sqrt(2)/2*I); // r = 1, θ = pi/4
    printf("4*log(sqrt(2)/2+sqrt(2)i/2) = %.1f%+fi\n", creal(4*z2), cimag(4*z2));
 
    double complex z3 = clog(-1); // r = 1, θ = pi
    printf("log(-1+0i) = %.1f%+fi\n", creal(z3), cimag(z3));
 
    double complex z4 = clog(conj(-1)); // or clog(CMPLX(-1, -0.0)) in C11
    printf("log(-1-0i) (the other side of the cut) = %.1f%+fi\n", creal(z4), cimag(z4));
}

出力:

2*log(i) = 0.0+3.141593i
4*log(sqrt(2)/2+sqrt(2)i/2) = 0.0+3.141593i
log(-1+0i) = 0.0+3.141593i
log(-1-0i) (the other side of the cut) = 0.0-3.141593i

[編集] 参考文献

  • C11 standard (ISO/IEC 9899:2011):
  • 7.3.7.2 The clog functions (p: 195)
  • 7.25 Type-generic math <tgmath.h> (p: 373-375)
  • G.6.3.2 The clog functions (p: 543-544)
  • G.7 Type-generic math <tgmath.h> (p: 545)
  • C99 standard (ISO/IEC 9899:1999):
  • 7.3.7.2 The clog functions (p: 176-177)
  • 7.22 Type-generic math <tgmath.h> (p: 335-337)
  • G.6.3.2 The clog functions (p: 478-479)
  • G.7 Type-generic math <tgmath.h> (p: 480)

[編集] 関連項目

(C99)(C99)(C99)
eを底とする複素指数関数を計算します
(関数) [edit]
(C99)(C99)
自然対数 (ln(x)) を計算します
(関数) [edit]