On topo of conflicting r
variable name and returnign wrong type the header for cpow
is like this:
double complex cpow( double complex x, double complex y );
What you are calling it with is:
double complex z = cpow(double r,double .2);
Complex numbers have 2 components real and imaginary. As your operands are real domain you need to cast them to complex domain by copying them to real part and set imaginary part to zero.
I never used complex.h
usually use my own code for stuff like this so I do not know how exactly cast this. According to this I would expect this would work:
double area(double r)
{
double complex cr,ce,cz;
r = (1.0-(r/1.83))*1.25;
cr=r+0.0*I;
ce=0.2+0.0*I;
cz=cpow(cr,cc);
return creal(cz);
}
However as its most likely implemented like a macro its possible you need to write double complex
before each operand of cpow
... Also the I
I saw to be use as i
too in the same linked doc... its really confusing which one or if booth or if they are required or not.
However using cpow
from complex.h
will not resolve your problem as it most certainly does not compute the correct k
for cln
and uses most likely just k=0
which will lead to non real results !!! If you use the last version of mine mypow
in the linked answer you do not need complex.h
nor anything else but math.h
...
Also only now its clear you are computing area. So why is r
even negative? If you have some parts to add and some to substract from the total area then its OK however if not then maybe you just have wrong equation and after its correction you could use real domain pow
... such case is called XY problem ... you want to solve problem X by solving problem Y as you think it would lead you closer to solution however if X and Y are not related you just wasting time.