C atan()

The atan() function defined in the math.h header file. It helps to return the arc tangent value of the given number in radians.


double atan(double x); #where x should be a double

atan() Parameters:

The atan() function takes a single parameter in the range of any value from negative to positive. Using cast operator we can explicitly convert the type to double to find the atan() of type int, float, or long double.

Parameter Description Required / Optional
double value Any double value from negative to positive Required

atan() Return Value

The return value of atan() function is in the range of [-pi/2,+pi/2] in radians.

Input Return Value
x = [-1, +1] [-pi/2,+pi/2] in radians
-1 > x or x > 1 NaN (not a number)

Examples of atan() 

Example 1: Working of atan() function in C?


#include <stdio.h>
#include <math.h>
#define PI 3.141592654

int main()
{
    double n = 1.0;
    double output;

    output = atan(n);

    printf("The Inverse of tan(%.2f) is equal to %.2f in radians", n, output);

    // Converting radians to degrees
    output = (output * 180) / PI;
    printf("\nThe Inverse of tan(%.2f) is equal to %.2f in degrees", n, output);

    return 0;
}

Output:


The Inverse of tan(1.00) is equal to 0.79 in radians
The Inverse of tan(1.00) is equal to 45 in degrees

Example 2: How asinh() works in C?


#include <stdio.h>
#include <math.h>
int main () {
   double v, out, value;
   v = 1.0;
   value = 180.0 / PI;

   out = atan (v) * value;
   printf("The arc tangent of %lf is %lf degrees", v, out);
   
   return(0);
}

Output:


The arc tangent of 1.000000 is 45.000000 degrees