| Types and the imaginary constant | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
| Manipulation | |||||||||||||||||||||||||||||||
| Power and exponential functions | |||||||||||||||||||||||||||||||
| Trigonometric functions | |||||||||||||||||||||||||||||||
| Hyperbolic functions | |||||||||||||||||||||||||||||||
Defined in header <complex.h> | ||
| (1) | (since C99) | |
| (2) | (since C99) | |
| (3) | (since C99) | |
Defined in header <tgmath.h> | ||
#define tanh( z ) | (4) | (since C99) |
z.z has typelongdoublecomplex,ctanhl is called. ifz has typedoublecomplex,ctanh is called, ifz has typefloatcomplex,ctanhf is called. Ifz is real or integer, then the macro invokes the corresponding real function (tanhf,tanh,tanhl). Ifz is imaginary, then the macro invokes the corresponding real version of the functiontan, implementing the formulatanh(iy) = i tan(y), and the return type is imaginary.Contents |
| z | - | complex argument |
If no errors occur, complex hyperbolic tangent ofz is returned
Errors are reported consistent withmath_errhandling
If the implementation supports IEEE floating-point arithmetic,
z is+0+0i, the result is+0+0iz isx+∞i (for any[1] finite x), the result isNaN+NaNi andFE_INVALID is raisedz isx+NaN (for any[2] finite x), the result isNaN+NaNi andFE_INVALID may be raisedz is+∞+yi (for any finite positive y), the result is1+0iz is+∞+∞i, the result is1±0i (the sign of the imaginary part is unspecified)z is+∞+NaNi, the result is1±0i (the sign of the imaginary part is unspecified)z isNaN+0i, the result isNaN+0iz isNaN+yi (for any non-zero y), the result isNaN+NaNi andFE_INVALID may be raisedz isNaN+NaNi, the result isNaN+NaNiz is0+∞i, the result should be0+NaNiz is0+NaNi, the result should be0+NaNi| ez -e-z |
| ez +e-z |
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.
#include <stdio.h>#include <math.h>#include <complex.h> int main(void){doublecomplex z= ctanh(1);// behaves like real tanh along the real lineprintf("tanh(1+0i) = %f%+fi (tanh(1)=%f)\n",creal(z),cimag(z),tanh(1)); doublecomplex z2= ctanh(I);// behaves like tangent along the imaginary lineprintf("tanh(0+1i) = %f%+fi ( tan(1)=%f)\n",creal(z2),cimag(z2),tan(1));}
Output:
tanh(1+0i) = 0.761594+0.000000i (tanh(1)=0.761594)tanh(0+1i) = 0.000000+1.557408i ( tan(1)=1.557408)
(C99)(C99)(C99) | computes the complex hyperbolic sine (function)[edit] |
(C99)(C99)(C99) | computes the complex hyperbolic cosine (function)[edit] |
(C99)(C99)(C99) | computes the complex arc hyperbolic tangent (function)[edit] |
(C99)(C99) | computes hyperbolic tangent (\({\small\tanh{x} }\)tanh(x)) (function)[edit] |
C++ documentation fortanh | |