Name

cpow

Synopsis

Raises a complex number to a complex power

#include <complex.h>
double complexcpow( double complex x, double complex y );
float complex cpowf( float complex x, float complex y );
long double complex cpowl( long double complex x, long double complex y );

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 xy.

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.

See Also

The corresponding function for real numbers, pow(); the complex math functions cexp(), clog(), cpow(), csqrt()

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.