Math Atanh Function - C++ Programming Tutorial
C++ Course / Math Functions / Math Atanh Function

Math Atanh Function

BLUF: Mastering Math Atanh Function is a critical step in becoming a proficient C++ developer. This lesson provides a deep dive into the syntax, performance considerations, and real-world applications of this concept.
Key Performance Insight: Math Atanh Function

C++ is renowned for its efficiency. Learn how Math Atanh Function enables low-level control and high-performance computing in the tutorial below.

C++ Math atanh

The function calculates the inverse hyperbolic tangent of an angle provided in radians.

An inverse hyperbolic tangent, also known as arc hyperbolic tangent, reverses the operation of the hyperbolic tangent function.

Syntax

Suppose an angle given in radian is 'x':

Example

float atanh(float x);
double atanh(double x);
long double atanh(long double x);
double atanh(integral x);

Note: The return_type can be float, double long double.

Parameter

The input parameter 'x' represents the value for which the hyperbolic arctangent will be calculated.

Return value

It returns the arc hyperbolic tangent of x.

Parameter Return value
-1 Finite value
x= -1 -inf
x=1 inf
x_PRESERVE9__1 Not a Number(nan)

Example 1

Let's consider a basic scenario where the value of x falls within the range of -1 to 1.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  float x=0.5;
  std::cout << "value of x is :" <<x <<std::endl;
  cout<<"atanh(x) : "<<atanh(x);
  return 0;
}

Output:

Output

value of x is :0.5
atanh(x) : 0.549306

In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and provides the result of 0.54.

Example 2

Let's examine a basic scenario where the value assigned to x is -1.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  int x= -1;
  std::cout << "value of x is :" <<x <<std::endl;
  cout<<"atanh(x) : "<<atanh(x);
  return 0;
}

Output:

Output

value of x is :-1
atanh(x) : -inf

In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and yields the result ?inf.

Example 3

Let's examine a basic scenario where the value assigned to x is 1.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  int x=1;
  std::cout << "value of x is :" <<x <<std::endl;
  cout<<"atanh(x) : "<<atanh(x);
  return 0;
}

Output:

Output

value of x is :1
atanh(x) : inf

In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and outputs the result as inf.

Example 4

Let's consider a straightforward illustration where the value of x exceeds 1.

Example

#include <iostream>
#include<math.h>
using namespace std;
int main()
{
  int x=5;
  std::cout << "value of x is :" <<x <<std::endl;
  cout<<"atanh(x) : "<<atanh(x);
  return 0;
}

Output:

Output

value of x is :5
atanh(x) : -nan

In this instance, the atanh(x) function calculates the inverse hyperbolic tangent of x and yields the result -nan.

Input Required

This code uses input(). Please provide values below:

Logic Practice
Install Logic Practice
Add to home screen for a faster app-like experience