C complex.h ctanh,ctanhf and ctanhl


The C <complex.h> ctanh,ctanhf and ctanhl function compute the hyperbolic tangent of the complex number.The declaration of the function is given below.

1 double complex ctanh(double complex z);
2 float complex ctanhf(float complex z);
3 long double complex ctanhl(long double complex z);

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

i)The ‘ctanh’ return the hyperbolic tangent as double complex type.
ii)The ‘ctanhf’ return the hyperbolic tangent as float complex type and
iii)The ‘ctanhl’ return the hyperbolic tangent as long double complex type.

Some points to note:

i)The ctanh,ctanhf and ctanhl is computed using the formula:

C complex.h ctanh,ctanhf and ctanhl

“tanh=ctanh=ctanhf=ctanhl”

double complex ctanh(double complex z);

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

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

Code example

double complex c1=345.66 +I*11.22 , c2 ;

c2=ctanh( c1 ) ;

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

Output in Code::Blocks,

Real part of c2=1.000000
Imaginary part of c2=-0.000000



float complex ctanhf(float complex z);

This function return the hyperbolic tangent as float type.

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

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

Code example

float complex c1=345.66 +I*11.22 , c2 ;

c2=ctanhf( c1 ) ;

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

Output in Code::Blocks ,

Real part of c2=1.000000
Imaginary part of c2=-0.000000


long double complex ctanhl(long double complex z);

This function return the hyperbolic tangent as long double type.

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

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

Code example

long double complex c1=345.66 +I*11.22 , c2 ;

c2=ctanhl( c1 ) ;

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

Output in Code::blocks,

Real part of c2=1.000000
Imaginary part of c2=-0.000000


*Side Note

Some facts about ctanh,ctanhf and ctanhl ,

  ➥ctanh(conj(z))=conj(ctanh(z)) and ctanh is odd.

  ➥ctanh(+0 + i0) returns +0+i0.

  ➥ctanh(x + i∞) returns NaN+iNaN and raises the invalid floating-point exception, for finite x.

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

  ➥ctanh(+∞ + iy) returns 1+i0sin(2y), for positive-signed finite y.

  ➥ctanh(+∞ + i∞) returns 1±i0(where the sign of the imaginary part of the result is unspecified).

  ➥ctanh(+∞ + iNaN) returns 1±i0(where the sign of the imaginary part of the result is unspecified).

  ➥ctanh(NaN + i0) returns NaN+i0.

  ➥ctanh(NaN + iy) returns NaN+iNaN and optionally raises the invalid floating-point exception, for all nonzero numbers y.

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

Link :C complex.h conj,conjf and conjl