std::atanh(std::complex)(3)
π std::atanh(std::complex) β the C++ Standard Library one, bestie
Okay so picture this: it's a (3) manual page, it lives in the C++ Standard Library, and its whole entire personality is std::atanh(std::complex). That's the name, that's the vibe, we move. π¦
β¨ Synopsis β¨
First things first, she's Defined in header <complex> β don't forget to bring her along.
template< class T > (since C++11)
complex<T> atanh( const complex<T>& z );
So what does she do? She computes the complex arc hyperbolic tangent of z, and the branch cuts sit outside the interval [β1; +1] along the real axis. Lowkey iconic behavior tbh. π
πΈ Parameters πΈ
zβ a complex value. that's it, that's the whole parameter list, she's low-maintenance.
π Return value π
If literally no errors happen (a blessed day β¨), you get the complex arc hyperbolic tangent of z back, and it lives in the range of a half-strip that is mathematically unbounded along the real axis and sits in the interval [βiΟ/2; +iΟ/2] along the imaginary axis. Slay.
π Error handling and special values π
Errors get reported consistent with math_errhandling. fr fr, that's the system.
If the implementation supports IEEE floating-point arithmetic, here's the whole mood board:
std::atanh(std::conj(z)) == std::conj(std::atanh(z))std::atanh(-z) == -std::atanh(z)- If
zis(+0,+0), the result is(+0,+0) - If
zis(+0,NaN), the result is(+0,NaN) - If
zis(+1,+0), the result is(+β,+0)andFE_DIVBYZEROis raised - If
zis(x,+β)(for any finite positivex), the result is(+0,Ο/2) - If
zis(x,NaN)(for any finite nonzerox), the result is(NaN,NaN)andFE_INVALIDmay be raised - If
zis(+β,y)(for any finite positivey), the result is(+0,Ο/2) - If
zis(+β,+β), the result is(+0,Ο/2) - If
zis(+β,NaN), the result is(+0,NaN) - If
zis(NaN,y)(for any finitey), the result is(NaN,NaN)andFE_INVALIDmay be raised - If
zis(NaN,+β), the result is(Β±0,Ο/2)(the sign of the real part is unspecified β yeah, she's mysterious like that π) - If
zis(NaN,NaN), the result is(NaN,NaN)
π§ Notes π§
Bestie, this is the part where we get a little pedantic and honestly we should. π
Even though the C++ standard calls this function "complex arc hyperbolic tangent", the inverse functions of the hyperbolic functions are actually the area functions. Their argument is the area of a hyperbolic sector, not an arc. So the correct name is "complex inverse hyperbolic tangent" and, less common, "complex area hyperbolic tangent". The way that etymology stayed relevant π
Inverse hyperbolic tangent is a multivalued function and she requires a branch cut on the complex plane. By convention the branch cut is placed at the line segments (-β,-1] and [+1,+β) of the real axis.
The mathematical definition of the principal value of the inverse hyperbolic tangent is:
atanh z = ( ln(1+z) - ln(1-z) ) / 2
And for any z:
atanh(z) = atan(iz) / i
π Example π
// Run this code
#include <complex>
#include <iostream>
int main()
{
std::cout << std::fixed;
std::complex<double> z1(2.0, 0.0);
std::cout << "atanh" << z1 << " = " << std::atanh(z1) << '\n';
std::complex<double> z2(2.0, -0.0);
std::cout << "atanh" << z2 << " (the other side of the cut) = "
<< std::atanh(z2) << '\n';
// for any z, atanh(z) = atanh(iz) / i
std::complex<double> z3(1.0, 2.0);
std::complex<double> i(0.0, 1.0);
std::cout << "atanh" << z3 << " = " << std::atanh(z3) << '\n'
<< "atan" << z3 * i << " / i = " << std::atan(z3 * i) / i
<< '\n';
}
β Output β
atanh(2.000000,0.000000) = (0.549306,1.570796)
atanh(2.000000,-0.000000) (the other side of the cut) =
(0.549306,-1.570796)
atanh(1.000000,2.000000) = (0.173287,1.178097)
atan(-2.000000,1.000000) / i = (0.173287,1.178097)
π See also π
asinh(std::complex)β computes area hyperbolic sine of a complex number (C++11) β arsinh(z) β function templateacosh(std::complex)β computes area hyperbolic cosine of a complex number (C++11) β arcosh(z) β function templatetanh(std::complex)β computes hyperbolic tangent of a complex number β tanh(z) β function templateatanh,atanhf,atanhl(C++11) β computes the inverse hyperbolic tangent β artanh(x) β function- C documentation for
catanhβ for when you wanna hang out in C land π
Okay that's the whole page, no gatekeeping, no cap. Now go forth and compute your arc hyperbolic tangents, but like, correctly. π«Ά
Sign-off time, bestie: this little masterpiece came from http://cppreference.com, dated 2024.06.10, and it's the std::atanh(std::complex)(3) page. Periodt. π₯
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms