C++ Standard Library C++ STL Library

C++ <cmath> - atan() Function



The C++ <cmath> atan() function returns arc tangent of a value. The returned value will be in the range -𝜋/2 through 𝜋/2.

Note: atan() is the inverse of tan().

Syntax

double atan (double x);
float atan (float x);
long double atan (long double x);
double atan (double x);
float atan (float x);
long double atan (long double x);
//additional overloads for integral types
double atan (T x);  

Parameters

x Specify the value.

Return Value

Returns the arc tangent of the value.

Example:

In the example below, atan() function is used to find out the arc tangent of a given value.

#include <iostream>
#include <cmath>
using namespace std;
 
int main (){
  cout<<atan(0.5)<<"\n";
  cout<<atan(1)<<"\n";
  cout<<atan(2)<<"\n";
  return 0;
}

The output of the above code will be:

0.463648
0.785398
1.10715

❮ C++ <cmath> Library