C complex.h cacosh,cacoshf and cacoshl


The C <complex.h> cacosh,cacoshf and cacoshl functions compute the arc hyperbolic cosine of the complex number.The declaration of the function is given below.

1 double complex cacosh(double complex z);
2 float complex cacoshf(float complex z);
3 long double complex cacoshl(long double complex z);

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

i)The ‘cacosh’ return the arc cosine as double complex type.
ii)The ‘cacoshf’ return the arc cosine as float complex type and
iii)The ‘cacoshl’ return the arc cosine as long double complex type.

Some points to note:

i) The arc hyperbolic cosine is computed using the formula.

C complex.h cacosh,cacoshf and cacoshl

ii)The function compute the complex arc hyperbolic cosine of ‘x’,with a branch cut at values less than 1 along the real axis.

iii)The function returns a complex whose value is in the range of a half-strip of non-negative values along the real axis and in the interval [−iπ , +iπ] along the imaginary axis.

double complex cacosh(double complex z);

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

Return type
double complex -The complex arc hyperbolic cosine of ‘x’.

Code example

double complex c1=4.56 +I*123.457 , c2 ;

c2=cacosh( c1 ) ;

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

Output,

Real part of c2=5.509738
Imaginary part of c2=1.533878





float complex cacoshf(float complex z);

This function compute the arc hyperbolic cosine and return it as float type.

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

Return type
float complex -The complex arc hyperbolic cosine of ‘x’.

Code example

float complex c1=4.56 +I*123.457 , c2 ;

c2=cacoshf( c1 ) ;

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

Output,

Real part of c2=5.509738
Imaginary part of c2=1.533878


long double complex cacoshl(long double complex z);

This function compute the arc hyperbolic cosine and return it as float type.

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

Return type
long double complex -The complex arc hyperbolic cosine of ‘x’.

Code example

long double complex c1=4.56 +I*123.457 , c2 ;

c2=cacoshl( c1 ) ;

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

Output,

Real part of c2=5.509738
Imaginary part of c2=1.533878

You might have noticed all the three functions cacosh,cacoshf and cacoshl return the same value.This shows the similarity of all the functions.The only difference is their return type.So using coshf for double or long double typ complex number may result in loss of precision.

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


*Side Note

Some cases of cacosh function (also holds true for cacoshf and cacoshl),

  ➥cacosh( conj(z) )=conj( cacosh(z) )

  ➥cacosh(±0 + i0) returns +0 + iπ/2.

  ➥cacosh(±0 + iNaN) ,returns (±NaN , iNaN).

  ➥cacosh(x + i∞) returns +∞ + iπ/2 , for finite x.

  ➥cacosh(x + iNaN) returns NaN+iNaN and optionally raises the “invalid” floating-point exception, for finite x.

  ➥cacosh(−∞ + iy) returns +∞ +iπ ,for positive-signed finite ‘y’.

  ➥cacosh(+∞ + iy) returns +∞ + i0, for positive-signed finite ‘y’.

  ➥cacosh(−∞ + i∞) returns +∞ + i3π/4.

  ➥cacosh(+∞ + i∞) returns +∞ +iπ/4.

  ➥cacosh(±∞ + iNaN) returns +∞ +iNaN.

  ➥cacosh(NaN + iy) returns NaN+iNaN and optionally raises the “invalid” floating-point exception, for finite ‘y’.

  ➥cacosh(NaN + i∞) returns +∞ +iNaN.

  ➥cacosh(NaN + iNaN) returns NaN+iNaN.

Link :C complex.h conj,conjf and conjl