function
<cmath> <ctgmath>

atan

double atan(double x);
     double atan  (double x);
      float atanf (float x);
long double atanl (long double x);
     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);
     double atan (T x);           // additional overloads for integral types
Compute arc tangent
Returns the principal value of the arc tangent of x, expressed in radians.

In trigonometrics, arc tangent is the inverse operation of tangent.

Notice that because of the sign ambiguity, the function cannot determine with certainty in which quadrant the angle falls only by its tangent value. See atan2 for an alternative that takes a fractional argument instead.

Header <tgmath.h> provides a type-generic macro version of this function.
This function is overloaded in <valarray> (see valarray atan).
Additional overloads are provided in this header (<cmath>) for the integral types: These overloads effectively cast x to a double before calculations (defined for T being any integral type).

This function is also overloaded in <complex> and <valarray> (see complex atan and valarray atan).

Parameters

x
Value whose arc tangent is computed.

Return Value

Principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.
One radian is equivalent to 180/PI degrees.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
/* atan example */
#include <stdio.h>      /* printf */
#include <math.h>       /* atan */

#define PI 3.14159265

int main ()
{
  double param, result;
  param = 1.0;
  result = atan (param) * 180 / PI;
  printf ("The arc tangent of %f is %f degrees\n", param, result );
  return 0;
}


Output:

The arc tangent of 1.000000 is 45.000000 degrees.

See also