Format
#include <math.h> double atan(double x); double atan2(double y, double x);
Language Level: ANSI, POSIX, XPG4
atan and atan2 calculate the arctangent of x and y/x,
respectively.
Return Value
atan returns a value in the range -PI/2 to PI/2 radians.
atan2 returns a value in the range -PI to PI radians. If both
arguments of atan2 are zero, the function sets errno to EDOM, and
returns a value of 0.
Example
This example calculates arctangents using the atan and
atan2 functions.
#include <math.h> #include <stdio.h>
int main(void)
{
double a,b,c,d;
c = 0.45;
d = 0.23;
a = atan(c);
b = atan2(c,d);
printf("atan( %lf ) = %lf\n", c, a);
printf("atan2( %lf, %lf ) = %lf\n", c, d, b);
return 0;
/************************************************
The output should be:
atan( 0.450000 ) = 0.422854
atan2( 0.450000, 0.230000 ) = 1.098299
************************************************/
}
![]()
acos -- Calculate Arccosine
asin -- Calculate Arcsine
cos -- Calculate Cosine
cosh -- Calculate Hyperbolic Cosine
_fpatan -- Calculate Arctangent
_fptan -- Calculate Tangent
sin -- Calculate Sine
sinh -- Calculate Hyperbolic Sine
tan -- Calculate Tangent
tanh -- Calculate Hyperbolic Tangent
<math.h>