C++ atanh()
Anonymous contributor
Published Dec 3, 2022
Contribute to Docs
The atanh() function returns the inverse hyperbolic tangent of a number in radians.
Syntax
atanh(x)
This function requires an x parameter x in the range of [-1, 1]. Its data type can be double, float, or long double.
- If the value of
xis outside of its range, a range error occurs. - If
xis±1, a pole error occurs.
For C++ implementations that support floating-point math:
- If
xis±0, it is returned unmodified. - If
xis±1,±∞is returned andFE_DIVBYZEROis raised. - If
|x|> 1,NaNis returned andFE_INVALIDis raised. - If
xisNaN,NaNis returned.
Example
The following example uses atanh() to return the result in radians:
#include <iostream>#include <cmath>#define PI 3.141592654using namespace std;int main() {double x = 0.32, result;result = atanh(x);cout << "atanh(x) = " << result << " radian" << endl;// result in degreescout << "atanh(x) = " << result*180/PI << " degree" << endl;return 0;}
This example produces the following output:
atanh(x) = 0.331647 radianatanh(x) = 19.002 degree
Codebyte Example
The following example is runnable:
All contributors
- Anonymous contributor
Contribute to Docs
- Learn more about how to get involved.
- Edit this page on GitHub to fix an error or make an improvement.
- Submit feedback to let us know how we can improve Docs.
Learn C++ on Codecademy
- Looking for an introduction to the theory behind programming? Master Python while learning data structures, algorithms, and more!
- Includes 6 Courses
- With Professional Certification
- Beginner Friendly.75 hours
- Learn C++ — a versatile programming language that’s important for developing software, games, databases, and more.
- Beginner Friendly.11 hours