# C complex.h carg , cargf and cargl

The C <complex.h> carg , cargf and cargl function compute the phase angle of the complex number with a branch cutting along the negative real axis.The declaration of the carg,cargf and cargl functions is shown below.

1 double carg(double complex z);
2 float cargf(float complex z);
3 long double cargl(long double complex z);

All the three functions are same,they compute the phase angle of the complex number.The only difference is in their return type.

i)The carg return the phase angle as double type
ii)The cargf return the phase angle as float type and
iii)The cargl return the phase angle as long double type.

Some points to note (Note these points is common to all the three functions carg,cargf and cargl):

i)All the three functions return the value of the argument in the interval [−π , +π].

ii)These function is equivalent to computing catan2(cimag(x), creal(x)),where ‘x’ is a complex number.

ii)Suppose x+iy is a complex number then consider the value ‘x’ and ‘y’ depicted in the imaginary-axis and real-axis.

The angle ‘Θ’ is known as the phase angle of the complex number.

#### double carg(double complex z);

Parameters:
z -The complex number whose phase angle is to be computed.

Return type
double-The phase angle of the ‘z’ complex number as double type.

Code example

double complex c1=777.889 +I*11.23 ;
printf( “Phase angle of c1=%lf” , carg(c1) );
printf( “\natan2( cimag(c1) , creal(c1))=%lf” , atan2( cimag(c1) , creal(c1)) );

Output,

Phase angle of c1=0.014436
atan2( cimag(c1) , creal(c1))=0.014436

#### float cargf(float complex z);

The cargf return the phase angle as float type.

Parameters:
z -The complex number whose phase angle is to be computed.

Return type
float-The phase angle of the ‘z’ complex number as float type.

Code example

float complex cf=444.55 +I*00.22 ;

printf( “Phase angle of cf=%f”, cargf(cf) );

Output,

Phase angle of cf=0.000495

#### long double cargl(long double complex z);

The cargl return the phase angle as long double type.

Parameters:
z -The complex number whose phase angle is to be computed.

Return type
long double-The phase angle of the ‘z’ complex number as long double type.

Code example

long double complex cf=999.222 +I* 11.22 ;

printf( “Phase angle of cl=%Lf”, cargl(cl) );

Output,

Phase angle of cl=0.011228