I want to calculate complex number angles and magnitude and I good with them
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <complex.h>
double pi = 4 * atan(1.0);
int main() {
double complex z = cexp(I * -1 * pi * 1.2 - 1);
printf("%f + %f * i\n", creal(z), cimag(z));
double complex base = clog(z);
printf("%f + %f * i\n", creal(base), cimag(base));
double arg = carg(base);
printf(" Angle of z in radian %f and as degree %f \n", arg, arg * 180 / pi);
double magnitude = cabs(base);
printf("Magnitude of z %f \n", magnitude);
return 0;
}
this program prints
-0.297621 + 0.216234 * i
-1.000000 + 2.513274 * i
Angle of z in radian 1.949480 and as degree 111.696984
Magnitude of z 2.704912
But, This result don't have negative imaginary component. But all complex numbers have positive one. How can I get a value at the third quadrant of the complex plane?