Common mathematical functions | |||||||||||||||||||||||||||||||
Mathematical special functions(C++17) | |||||||||||||||||||||||||||||||
Mathematical constants(C++20) | |||||||||||||||||||||||||||||||
Basic linear algebra algorithms(C++26) | |||||||||||||||||||||||||||||||
Data-parallel types (SIMD)(C++26) | |||||||||||||||||||||||||||||||
Floating-point environment(C++11) | |||||||||||||||||||||||||||||||
Complex numbers | |||||||||||||||||||||||||||||||
Numeric array (valarray ) | |||||||||||||||||||||||||||||||
Pseudo-random number generation | |||||||||||||||||||||||||||||||
Bit manipulation(C++20) | |||||||||||||||||||||||||||||||
Saturation arithmetic(C++26) | |||||||||||||||||||||||||||||||
Factor operations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Interpolations | |||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||
Generic numeric operations | |||||||||||||||||||||||||||||||
| |||||||||||||||||||||||||||||||
C-style checked integer arithmetic | |||||||||||||||||||||||||||||||
|
Defined in header <complex> | ||
template<class T> complex<T> tanh(const complex<T>& z); | (since C++11) | |
Computes complex hyperbolic tangent of a complex valuez.
Contents |
z | - | complex value |
If no errors occur, complex hyperbolic tangent ofz is returned.
Errors are reported consistent withmath_errhandling.
If the implementation supports IEEE floating-point arithmetic,
(+0,+0)
, the result is(+0,+0)
.(x,+∞)
(for any[1] finite x), the result is(NaN,NaN)
andFE_INVALID is raised.(x,NaN)
(for any[2] finite x), the result is(NaN,NaN)
andFE_INVALID may be raised.(+∞,y)
(for any finite positive y), the result is(1,+0)
.(+∞,+∞)
, the result is(1,±0)
(the sign of the imaginary part is unspecified).(+∞,NaN)
, the result is(1,±0)
(the sign of the imaginary part is unspecified).(NaN,+0)
, the result is(NaN,+0)
.(NaN,y)
(for any non-zero y), the result is(NaN,NaN)
andFE_INVALID may be raised.(NaN,NaN)
, the result is(NaN,NaN)
.z
is(0,∞)
, the result should be(0,NaN)
.z
is(0,NaN)
, the result should be(0,NaN)
.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 <cmath>#include <complex>#include <iostream> int main(){std::cout<<std::fixed;std::complex<double> z(1.0,0.0);// behaves like real tanh along the real linestd::cout<<"tanh"<< z<<" = "<<std::tanh(z)<<" (tanh(1) = "<<std::tanh(1)<<")\n"; std::complex<double> z2(0.0,1.0);// behaves like tangent along the imaginary linestd::cout<<"tanh"<< z2<<" = "<<std::tanh(z2)<<" ( tan(1) = "<<std::tan(1)<<")\n";}
Output:
tanh(1.000000,0.000000) = (0.761594,0.000000) (tanh(1) = 0.761594)tanh(0.000000,1.000000) = (0.000000,1.557408) ( tan(1) = 1.557408)
computes hyperbolic sine of a complex number (\({\small\sinh{z}}\)sinh(z)) (function template)[edit] | |
computes hyperbolic cosine of a complex number (\({\small\cosh{z}}\)cosh(z)) (function template)[edit] | |
(C++11) | computes area hyperbolic tangent of a complex number (\({\small\operatorname{artanh}{z}}\)artanh(z)) (function template)[edit] |
(C++11)(C++11) | computes hyperbolic tangent (\({\small\tanh{x}}\)tanh(x)) (function)[edit] |
applies the functionstd::tanh to each element of valarray (function template)[edit] | |
C documentation forctanh |