CKTIS / C
atan — C23 library function
`atan(double x)` from `<math.h>` returns the principal arctangent of its argument in radians in the interval `-π/2` through `π/2`; every real number is in its domain.
Version: C23
Syntax
double atan(double x);atan(double x) from <math.h> returns the principal arctangent of its argument in radians in the interval -π/2 through π/2; every real number is in its domain.
Use it to recover a slope angle from a component ratio when quadrant information is not required. The example actually computes atan(1.0) and prints an approximation of π/4.
In base C23 an infinite argument may cause a domain error, and a range error may occur when nonzero x is so close to zero that the correct result underflows. Annex F for IEC 60559 is what requires preserving signed ±0, returning ±π/2 for ±∞, and returning NaN for a NaN input.
Examples
#include <math.h>
#include <stdio.h>
int main(void) {
double radians = atan(1.0);
printf("%.3f\n", radians);
return 0;
}
Result
0.785
Use it to recover a slope angle from a component ratio when quadrant information is not required. The example actually computes `atan(1.0)` and prints an approximation of `π/4`.