ctanhf, ctanh, ctanhl - cppreference.com (original) (raw)
| Defined in header <complex.h> | ||
|---|---|---|
| float complex ctanhf( float complex z ); | (1) | (since C99) |
| double complex ctanh( double complex z ); | (2) | (since C99) |
| long double complex ctanhl( long double complex z ); | (3) | (since C99) |
| Defined in header <tgmath.h> | ||
| #define tanh( z ) | (4) | (since C99) |
1-3) Computes the complex hyperbolic tangent of z.
- Type-generic macro: If
zhas type long double complex,ctanhlis called. ifzhas type double complex,ctanhis called, ifzhas type float complex,ctanhfis called. Ifzis real or integer, then the macro invokes the corresponding real function (tanhf, tanh, tanhl). Ifzis imaginary, then the macro invokes the corresponding real version of the function tan, implementing the formula tanh(iy) = i tan(y), and the return type is imaginary.
Contents
- 1 Parameters
- 2 Return value
- 3 Error handling and special values
- 4 Notes
- 5 Example
- 6 References
- 7 See also
[edit] Parameters
[edit] Return value
If no errors occur, complex hyperbolic tangent of z is returned
[edit] Error handling and special values
Errors are reported consistent with math_errhandling
If the implementation supports IEEE floating-point arithmetic,
- ctanh(conj(z)) == conj(ctanh(z))
- ctanh(-z) == -ctanh(z)
- If
zis+0+0i, the result is+0+0i - If
zisx+∞i(for any[1] finite x), the result isNaN+NaNiand FE_INVALID is raised - If
zisx+NaN(for any[2] finite x), the result isNaN+NaNiand FE_INVALID may be raised - If
zis+∞+yi(for any finite positive y), the result is1+0i - If
zis+∞+∞i, the result is1±0i(the sign of the imaginary part is unspecified) - If
zis+∞+NaNi, the result is1±0i(the sign of the imaginary part is unspecified) - If
zisNaN+0i, the result isNaN+0i - If
zisNaN+yi(for any non-zero y), the result isNaN+NaNiand FE_INVALID may be raised - If
zisNaN+NaNi, the result isNaN+NaNi
- ↑ per DR471, this only holds for non-zero x. If
zis0+∞i, the result should be0+NaNi - ↑ per DR471, this only holds for non-zero x. If
zis0+NaNi, the result should be0+NaNi
[edit] Notes
Mathematical definition of hyperbolic tangent is tanh 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.
[edit] 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)); }
Output:
tanh(1+0i) = 0.761594+0.000000i (tanh(1)=0.761594) tanh(0+1i) = 0.000000+1.557408i ( tan(1)=1.557408)
[edit] References
C11 standard (ISO/IEC 9899:2011):
7.3.6.6 The ctanh functions (p: 194)
7.25 Type-generic math <tgmath.h> (p: 373-375)
G.6.2.6 The ctanh functions (p: 542)
G.7 Type-generic math <tgmath.h> (p: 545)
C99 standard (ISO/IEC 9899:1999):
7.3.6.6 The ctanh functions (p: 176)
7.22 Type-generic math <tgmath.h> (p: 335-337)
G.6.2.6 The ctanh functions (p: 477)
G.7 Type-generic math <tgmath.h> (p: 480)