English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

C++ atanh() function usage and example

C++ Library Function <cmath>

C ++the atanh() function in the radians returns the inverse hyperbolic tangent (inverse hyperbolic tangent).

atanh() function takes a single parameter and returns the inverse hyperbolic tangent of the value in radians.

This function is in<cmath>header file is defined.

tanh-1 x = atanh(x)

atanh() prototype [from C ++ 11standard library]

double atanh(double x);
float atanh(float x);
long double atanh(long double x);
double atanh(T x); // is of integer type

atanh() parameter

atanh() function takes a single mandatory parameter, ranging from [-1,1].

If the value is greater than1or less than-1occurs domain error.

atanh() return value

atanh() function returns the inverse hyperbolic tangent of the parameter passed to it.

atanh() return value table
parameter (x)return value
-1 <x <1finite value
x = -1-∞
x = 1
x <-1or x > 1NaN (not a number)

Example1: atanh() function in C ++How does it work?

#include <iostream>
#include <cmath>
#define PI 3.141592654
using namespace std;
int main()
{
	double x = 0.32, result;
	result = atanh(x);
	cout << "atanh(x) = " << result << " " << "radian" << endl;
	cout << "atanh(x) = " << result*180/PI << " " << endl;
	return 0;
}

The output when running the program is:

atanh(x) = 0.331647 radian
atanh(x) = 19.002 degree

Example2: atanh() function with integer type

#include <iostream>
#include <cmath>
#define PI 3.141592654
using namespace std;
int main()
{
	int x =; 1;
	double result;
	result = atanh(x);
	cout << "atanh(x) = " << result << " " << "radian" << endl;
	cout << "atanh(x) = " << result*180/PI << " " << endl;
	return 0;
}

The output when running the program is:

atanh(x) = inf radian
atanh(x) = inf degree

C++ Library Function <cmath>