User:Pankaj bagul 3037/sandbox
Cpow is library function in C programming language, useful to calculate power of a number raised to complex number.
It is the feature added to C programming language by 1999 standard i.e. C99.
Complex Power Function[edit | edit source]
Introduction[edit | edit source]
In mathematics, complex number is denoted by 'z' .
z = x + iy
In this number 'x' is the real part and 'y' is imaginary part.
'i' is imaginary unit ,where "i2 = -1 ".
Complex power is defined by the mathematical operation of exponentiation given by "z1z2" .
In C programming language , library function for this is given by Cpow.
Header File[edit | edit source]
Standard Library Header file :
<complex.h> (complex arithmetic)
Syntax for function[edit | edit source]
double complex cpow(double complex x, double complex y);
This function calculates the power of real number 'x' raised to y-th power ,where y is a complex number .
In mathematics ,by Euler's formula, eia = (cos a +i sin a).Here,cos and sin are trigonometric functions.
For xia,
xi .a = ei .a ln(x) = ( cos(a ln(x)) + i sin(a ln(x)) ) ; ln : logarithmic function to the base e.
Return Value[edit | edit source]
This function shall return the complex power function value.
Returns the complex power of base x raised to the y-th power using the principal branch, whose cuts are along the negative real axis.
Usage of Cpow function[edit | edit source]
//Program returns the complex number z3
#include<stdio.h>
#include<complex.h>
#include<math.h>
int main()
{ int x, y, p, q;
double complex z1, z2, z3; //complex variables declaration
scanf("%d %d %d %d", &x, &y, &p, &q);
z1 = (p + q * I);
z2 = (x + y * I);
z3 = cpow (z2, z1);
printf("%f + %f * i\n", creal(z3), cimag(z3));
return 0;
}