C complex.h ccos,ccof and ccosl


The C <complex.h> ccos,ccosf and ccosl functions compute the cosine of the complex number.The declaration of the function is given below.

1 double complex ccos(double complex z);
2 float complex ccosf(float complex z);
3 long double complex ccosl(long double complex z);

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

i)The ‘ccos’ return the cosine as double complex type.
ii)The ‘ccosf’ return the cosine as float complex type and
iii)The ‘ccosl’ return the cosine as long double complex type.

Some points to note:

i) The cosine is computed using the formula.

C complex.h ccos,ccosf and ccosl

double complex ccos(double complex z);

Parameters:
z – A complex number whose cosine is to be computed.

Return type
double complex -The complex cosine of ‘z’ as double type.

Code example

double complex c1=7.5 +I*2.4 , c2 ;

c2=ccos( c1 ) ;

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

Output,

Real part of c2=1.926234
Imaginary part of c2=-5.127323





float complex ccosf(float complex z);

This function compute the cosine of complex number and return it float type.

Parameters:
z – A complex number whose cosine is to be computed.

Return type
float complex -The complex cosine of ‘z’ as float type.

Code example

float complex c1=7.5 +I*2.4 , c2 ;

c2=ccosf( c1 ) ;

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

Output,

Real part of c2=1.926234
Imaginary part of c2=-5.127323


long double complex ccosl(long double complex z);

This function compute the cosine of complex number and return it long double type.

Parameters:
z – A complex number whose cosine is to be computed.

Return type
long double complex -The complex cosine of ‘z’ as long double type.

Code example

long double complex c1=7.5 +I*2.4 , c2 ;

c2=ccosl( c1 ) ;

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

Output,

Real part of c2=1.926234
Imaginary part of c2=-5.127323

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


*Side Note

Some cases of ccos function (also holds true for ccosf and ccosl),

  ➥ccos(conj(z) )=conj( ccos(z) )

  ➥ccos(±0 + i(±0)) , returns (1 , i0).

  ➥ccos(±0 + iNaN) ,returns ((nan , i(±0)).

  ➥ccos(±x + i(±∞) ) , returns (-∞ ,i(±∞) ) , for some finite value ‘x’.

  ➥ccos(x + iNaN) ,returns NaN + iNaN , for some finite value ‘x’.

  ➥ccos(±∞ + iy) ,returns NaN + iNaN , for some finite value ‘y’.

  ➥ccos(±∞ + i∞) ,returns (∞ , iNaN)

  ➥ccos(±∞ + iNaN) ,returns NaN +iNaN

  ➥ccos(NaN + iy) ,returns NaN +iNaN ,for some finite value ‘y’.

  ➥ccos(NaN + i(±)∞) ,returns NaN + iNaN .

  ➥ccos(NaN + iNaN) ,returns NaN+iNaN.

Link :C complex.h conj,conjf and cconjl