atan() Function

The atan() function computes the arc tangent of a given value and returns the corresponding angle in radians. It serves as the inverse operation of the tangent function in trigonometry, providing a way to determine an angle when its tangent is known. The resulting angle is within the interval [-π/2, +π/2].


Syntax of atan()

</>
Copy
double atan(double x);

Parameters

ParameterDescription
xValue whose arc tangent is computed.

Return Value

The function returns the principal arc tangent of the provided value, expressed in radians.

Note: The result is expressed in radians and lies within the interval [-π/2, +π/2]. Since atan() is the inverse of the tangent function, it does not resolve the quadrant ambiguity. For cases where the quadrant needs to be determined, consider using the atan2() function.


Examples for atan()

Example 1: Basic Calculation of Arc Tangent for a Positive Value

This example demonstrates how to calculate the arc tangent of a positive value using the atan() function.

Program

</>
Copy
#include <stdio.h>
#include <math.h>

int main() {
    double value = 1.0;
    double result = atan(value);
    printf("atan(%.2f) = %.4f radians\n", value, result);
    return 0;
}

Explanation:

  1. A variable is initialized with the value 1.0.
  2. The atan() function calculates the arc tangent of the given value.
  3. The resulting angle in radians is stored in a separate variable.
  4. The computed result is printed using printf().

Program Output:

atan(1.00) = 0.7854 radians

Example 2: Calculating Arc Tangent for a Negative Input Value

This example demonstrates the use of atan() to compute the arc tangent of a negative value, which results in a negative angle.

Program

</>
Copy
#include <stdio.h>
#include <math.h>

int main() {
    double value = -1.0;
    double result = atan(value);
    printf("atan(%.2f) = %.4f radians\n", value, result);
    return 0;
}

Explanation:

  1. A variable is initialized with the value -1.0.
  2. The atan() function computes the arc tangent of the negative value.
  3. The resulting angle, which is negative, is stored in a variable.
  4. The computed result is printed, demonstrating that the function returns a negative angle in radians.

Program Output:

atan(-1.00) = -0.7854 radians