C Programming/math.h/atan

From Wikibooks, open books for an open world
Jump to navigation Jump to search

atan is a function in math.h.[1] It computes arc tangent. It returns the principal value of the arc tangent of x, expressed in radians. In trigonometrics, arc tangent is the inverse operation of tangent. Note that because of sign ambiguity, function cannot determine in which quadrant the angle falls only by its tangent value. To determine quadrant, we can use atan2. Return value of this function is principal arc tangent of x, in the interval [-pi/2,+pi/2] radians.


Syntax[edit | edit source]

#include <math.h>
double atan ( double x );

Here, x is Floating point value.


Example[edit | edit source]

#include <math.h>
#include <stdio.h>

#define PI 3.14159265

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

Output[edit | edit source]

The arc tangent of 1.000000 is 45.000000 degrees.

References[edit | edit source]

  1. ISO/IEC 9899:1999 specification (PDF). p. 231, § 7.12.4.3.

External links[edit | edit source]