Format
#include <math.h>
double atan(double x);
double atan2(double y, double x);
Language Level: ANSI
Threadsafe: Yes.
Description
The atan() and atan2() functions calculate the arctangent of x and y/x, respectively.
Return Value
The atan() function returns a value in the range -π/2 to π/2 radians. The atan2() function returns a value in the range -π to π radians. If both arguments of the atan2() function are zero, the function sets errno to EDOM, and returns a value of 0.
Example that uses atan()
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);
}
/**************** Output should be similar to ******************
atan( 0.450000 ) = 0.422854
atan2( 0.450000, 0.230000 ) = 1.098299
*****************************************************************/
Related Information