- NAME
-
clog - natural logarithm of a complex number
- SYNOPSIS
#include <complex.h>
double complex clog (double complex z);
float complex clogf (float complex z);
long double complex clogl (long double complex z);
- CONFORMING TO
-
C99
- DESCRIPTION
-
The logarithm clog() is the inverse function of the exponential
cexp()
. Thus, ify = clog(z)
, thenz = cexp(y)
. The imaginary part ofy
is chosen in the interval[-pi,pi]
.
One has: clog(z) = log(cabs(z)) + I * carg(z)
Note that z
close to zero will cause an overflow.
link:src/clog.c[role=include]
- OUTPUT
$ gcc -Wall -lm clog.c $ ./a.out 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