ctanhf, ctanh, ctanhl

Header: <complex.h>

1-3) Computes the complex hyperbolic tangent of z.

# Declarations

float complex ctanhf( float complex z );

(since C99)

double complex ctanh( double complex z );

(since C99)

long double complex ctanhl( long double complex z );

(since C99)

#define tanh( z )

(since C99)

# Parameters

# Return value

If no errors occur, complex hyperbolic tangent of z is returned

# Notes

Hyperbolic tangent is an analytical function on the complex plane and has no branch cuts. It is periodic with respect to the imaginary component, with period πi, and has poles of the first order along the imaginary line, at coordinates (0, π(1/2 + n)). However no common floating-point representation is able to represent π/2 exactly, thus there is no value of the argument for which a pole error occurs.

# Example

#include <stdio.h>
#include <math.h>
#include <complex.h>
 
int main(void)
{
    double complex z = ctanh(1);  // behaves like real tanh along the real line
    printf("tanh(1+0i) = %f%+fi (tanh(1)=%f)\n", creal(z), cimag(z), tanh(1));
 
    double complex z2 = ctanh(I); // behaves like tangent along the imaginary line
    printf("tanh(0+1i) = %f%+fi ( tan(1)=%f)\n", creal(z2), cimag(z2), tan(1));
}

# See also