The function double atan(double x); returns the arc tangent of x, expressed in radians. Arc tangent is the inverse operation of tangent.
Function prototype of atan
double atan(double x);
- x : A floating point value whose arc tangent(inverse tangent) to be computed, in the interval [-INFINITY, INFINITY].
Return value of atan
Function atan returns the principal arc tangent of x, in the interval [-Pi/2, +Pi/2] radians.
C program using atan function
The following program shows the use of atan function to calculate inverse of tangent.
#include <stdio.h> #include <math.h> #define PI 3.14159 int main(){ double input, radian, degree; /* Range of tan function is -INFINITY to +INFINITY */ printf("Enter a number between -INFINITY to +INFINITY\n"); scanf("%lf", &input); radian = atan(input); /* * Radian to degree conversion * One radian is equal to 180/PI degrees. */ degree = radian * (180.0/PI); printf("The arc tan of %0.4lf is %0.4lf in radian\n", input, radian); printf("The arc tan of %0.4lf is %0.4lf in degree\n", input, degree); return 0; }
Output
Enter a number between -INFINITY to +INFINITY 1.0 The arc tan of 1.0000 is 0.7854 in radian The arc tan of 1.0000 is 45.0000 in degree
Enter a number between -INFINITY to +INFINITY 9999.0 The arc tan of 9999.0000 is 1.5707 in radian The arc tan of 9999.0000 is 89.9943 in degree