Name
cpow
Synopsis
Raises a complex number to a complex power
#include <complex.h> double complexcpow
( double complexx
, double complexy
); float complexcpowf
( float complexx
, float complexy
); long double complexcpowl
( long double complexx
, long double complexy
);
The cpow()
function raises
its first complex argument x
to the power
of the second argument, y
. In other
words, it returns the value of
x
y.
The cpow()
function has a
branch cut along the negative real axis to yield a unique
result.
Example
double complex z = 0.0 + 2.7 * I;
double complex w = 2.7 + 0.0 * I;
double complex c =cpow
(w, z); // Raise e to the power of i*2.7
printf("%.2f %+.2f \xD7 I raised to the power of %.2f %+.2f \xD7 I "
"is %.2f %+.2f \xD7 I.\n",
creal(w), cimag(w), creal(z), cimag(z), creal(c), cimag(c));
This code produces the following output:
2.70 +0.00 × I raised to the power of 0.00 +2.70 × I is -0.90 +0.44 × I.
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.