C complex.h clog,clogf and clogl


The C <complex.h> clog,clogf and clogl function compute the natural (base-e)logarithm of the complex number.The declaration of the function is given below.

1 double complex cexp(double complex z);
2 float complex cexpf(float complex z);
3 long double complex cexpl(long double complex z);

All the three functions compute the same value,the only difference between them is in their return type:

i)The ‘clog’ return the natural (base-e)logarithm of complex as double complex type.
ii)The ‘clogf’ return the natural (base-e)logarithm of complex as float complex type and
iii)The ‘clogl’ return the natural (base-e)logarithm of complex as long double complex type.

Some points to note:

i) The clog(z),clogf(z) and clogl(z) is same as computing loge(z).

ii)The branch of loge(z) cut along the negative real axis.

iii)The functions return values in the range of a strip mathematically unbounded along the real axis and in the interval [−iπ , +iπ] along the imaginary axis.

double complex clog(double complex z);

Parameters:
z – A complex number whose natural logarithm is to be computed.

Return type
double complex -The complex natural logarithm of ‘z’ as double type.

Code example

double complex c1=12.34 + I*11.22 , c2 ;

c2=cexp( c1 ) ;

printf( “Real part of c2=%lf”, creal(c2) ) ;
printf( “\nImaginary part of c2=%lf”, cimag(c2) ) ;

Output in Code::blocks,

Real part of c2=12.340000
Imaginary part of c2=11.220000






float complex clogf(float complex z);

This function return the natural logarithm as float type.

Parameters:
z – A complex number whose natural logarithm is to be computed.

Return type
float complex -The complex natural logarithm of ‘z’ as float type.

Code example

float complex c1=12.34 + I*11.22 , c2 ;

c2=cexpf( c1 ) ;

printf( “Real part of c2=%f”, crealf(c2) ) ;
printf( “\nImaginary part of c2=%f”, cimagf(c2) ) ;

Output in Code::blocks,

Real part of c2=12.340000
Imaginary part of c2=11.220000

Link : C complex.h creal,crealf and creall
Link : C complex.h cimag,cimagf and cimagl


long double complex clogl(long double complex z);

This function return the natural logarithm as long double type.

Parameters:
z – A complex number whose natural logarithm is to be computed.

Return type
long double complex -The complex natural logarithm of ‘z’ as long double type.

Code example

long double complex c1=12.34 + I*11.22 , c2 ;

c2=cexpl( c1 ) ;

printf( “Real part of c2=%Lf”, creall(c2) ) ;
printf( “\nImaginary part of c2=%Lf”, cimagl(c2) ) ;

Output in Code::blocks,

Real part of c2=12.340000
Imaginary part of c2=11.220000


*Side Note

Some facts about clog,clogf and clogl,

  ➥clog(conj(z))=conj(clog(z)).

  ➥clog(−0 + i0) returns −∞+iπ and raises the divide-by-zero floating-point exception.

  ➥clog(+0 + i0) returns −∞+i0 and raises the divide-by-zero floating-point exception.

  ➥clog(x + i∞) returns +∞+iπ/2, for finite x.

  ➥clog(x + iNaN) returns NaN+iNaN and optionally raises the invalid floating-point exception, for finite x.

  ➥clog(−∞ + iy) returns +∞+iπ,for finite positive-signed y.

  ➥clog(+∞ + iy) returns +∞+i0, for finite positive-signed y.

  ➥clog(−∞ + i∞) returns +∞+i3π/4.

  ➥clog(+∞ + i∞) returns +∞+iπ/4.

  ➥clog(±∞ + iNaN) returns +∞+iNaN.

  ➥clog(NaN + iy) returns NaN+iNaN and optionally raises the invalid floating-point exception, for finite y.

  ➥clog(NaN + i∞) returns +∞+iNaN.

  ➥clog(NaN + iNaN) returns NaN+iNaN.

Link :C complex.h conj,conjf and conjl