Defined in header <cmath> | ||
---|---|---|
(1) | ||
float tanh ( float arg ); | ||
float tanhf( float arg ); | (since C++11) | |
double tanh ( double arg ); | (2) | |
(3) | ||
long double tanh ( long double arg ); | ||
long double tanhl( long double arg ); | (since C++11) | |
double tanh ( IntegralType arg ); | (4) | (since C++11) |
arg
double
).arg | - | value of a floating-point or Integral type |
arg
(tanh(arg), or earg-e-arg/earg+e-arg) is returned. If a range error occurs due to underflow, the correct result (after rounding) is returned.
Errors are reported as specified in math_errhandling
.
If the implementation supports IEEE floating-point arithmetic (IEC 60559),
POSIX specifies that in case of underflow, arg
is returned unmodified, and if that is not supported, and implementation-defined value no greater than DBL_MIN, FLT_MIN, and LDBL_MIN is returned.
#include <iostream> #include <cmath> int main() { std::cout << std::showpos << "tanh(+1) = " << std::tanh(+1) << '\n' << "tanh(-1) = " << std::tanh(-1) << '\n' << "tanh(0.1)*sinh(0.2)-cosh(0.2) = " << std::tanh(0.1) * std::sinh(0.2) - std::cosh(0.2) << '\n' // special values: << "tanh(+0) = " << std::tanh(+0.0) << '\n' << "tanh(-0) = " << std::tanh(-0.0) << '\n'; }
Output:
tanh(+1) = +0.761594 tanh(-1) = -0.761594 tanh(0.1)*sinh(0.2)-cosh(0.2) = -1 tanh(+0) = +0 tanh(-0) = -0
(C++11)(C++11) | computes hyperbolic sine (\({\small\sinh{x} }\)sinh(x)) (function) |
(C++11)(C++11) | computes hyperbolic cosine (\({\small\cosh{x} }\)cosh(x)) (function) |
(C++11)(C++11)(C++11) | computes the inverse hyperbolic tangent (\({\small\operatorname{artanh}{x} }\)artanh(x)) (function) |
computes hyperbolic tangent of a complex number (\({\small\tanh{z} }\)tanh(z)) (function template) |
|
applies the function std::tanh to each element of valarray (function template) |
|
C documentation for tanh |
© cppreference.com
Licensed under the Creative Commons Attribution-ShareAlike Unported License v3.0.
https://en.cppreference.com/w/cpp/numeric/math/tanh