C complex.h cpow,cpowf and cpowl


The C <complex.h> cpow,cpowf and cpowl function compute the complex power value.The declaration of the function is given below.

1 double complex cpow(double complex x, double complex y);
2 float complex cpowf(float complex x, float complex y);
3 long double complex cpowl(long double complex x , long double complex y);

*Note calling cpow,cpowf and cpowl is same as computing xy.

All the three functions compute the same value,the only difference between them is in their return type:

i)The ‘cpow’ return the complex power xy as double complex type.
ii)The ‘cpowf’ return the complex power xy as float complex type and
iii)The ‘cpowl’ return the complex power xy as long double complex type.

double complex cpow(double complex x , double complex y);

Parameters:
x – The base value in xy.

y -The power value in xy.

Return type
double complex -The result of xy return as double type.

Code example

double complex c1=234.56 + I*11.11 ,
c2=99.99 +I*11 , c3 ;

c3=cpow( c2 ) ;

printf( “Real part of c3=%lf”, creal(c3) ) ;
printf( “\nImaginary part of c3=%lf”, cimag(c3) ) ;

Output in Code::Blocks,

Real part of c3=-245622712625751880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
Imaginary part of c3=620321963751178240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000



float complex cpowf(float complex x, float complex y);

This function return the computed value of xy as float type.

Parameters:
x – The base value in xy.

y -The power value in xy.

Return type
float complex -The result of xy return as float type.

Code example

float complex c1=234.56 + I*11.11 ,
c2=99.99 +I*11 , c3 ;

c3=cpowf( c2 ) ;

printf( “Real part of c3=%f”, crealf(c3) ) ;
printf( “\nImaginary part of c3=%f”, cimagf(c3) ) ;

Output in Code::Blocks,

Real part of c3=-1.#INF00
Imaginary part of c3=1.#INF00

The “-1.#INF00” and “1.#INF00” means infinity.Since float type cannot represent the resultant complex number infinity is returned as the resultant value.

Link : C complex.h creal,crealf and creall
Link : C complex.h cimag,cimagf and cimagl


long double complex cpowl(long double complex x , long double complex y);

This function return the computed value of xy as long double type.

Parameters:
x – The base value in xy.

y -The power value in xy.

Return type
long double complex -The result of xy return as long double type.

Code example

long double complex c1=234.56 + I*11.11 ,
c2=99.99 +I*11 , c3 ;

c3=cpowl( c2 ) ;

printf( “Real part of c3=%Lf”, creall(c3) ) ;
printf( “\nImaginary part of c3=%Lf”, cimagl(c3) ) ;

Output in Code::Blocks,

Real part of c3=-245622712625751880000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000
Imaginary part of c3=620321963751178240000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000.000000


*Side Note

The ‘cpow’ functions raise floating-point exceptions if appropriate for the calculation of the parts of the result, and may raise spurious exceptions.