Namespaces
Variants
Views
Actions

atan

From cppreference.com
< c‎ | numeric‎ | math
 
 
 
Common mathematical functions
Functions
Basic operations
(C99)
(C99)
(C99)
(C99)
(C99)
(C99)(C99)(C99)
Exponential functions
(C99)
(C99)
(C99)
(C99)
Power functions
(C99)
(C99)
Trigonometric and hyperbolic functions
(C99)
(C99)
(C99)
Error and gamma functions
(C99)
(C99)
(C99)
(C99)
Nearest integer floating point operations
(C99)(C99)(C99)
(C99)
(C99)(C99)(C99)
Floating point manipulation functions
(C99)(C99)
(C99)
(C99)
Classification
(C99)
(C99)
(C99)
Macro constants
 
Defined in header <math.h>
float       atanf( float arg );
(since C99)
double      atan( double arg );
long double atanl( long double arg );
(since C99)

Computes arc tangent of arg

Contents

[edit] Parameters

arg - floating point value

[edit] Return value

Arc tangent of arg in radians in the range of [-π/2; π/2] radians.

atan(+0) returns +0. atan(-0) returns -0

atan(+) returns +π/2. atan(-) returns -π/2

[edit] Example

#include <stdio.h>
#include <math.h>
#include <errno.h>
#include <fenv.h>
#define PI acos(-1)
 
int main()
{
    printf("atan(+1.0) = %+f\n", atan(+1.0));   /* +pi/4 */
    printf("atan(-1.0) = %+f\n", atan(-1.0));   /* -pi/4 */
    printf("\n");
 
    printf("atan(+0.0)      = %+.1f\n", atan(+0.0));
    printf("atan(-0.0)      = %+.1f\n", atan(-0.0));
    printf("atan(+INFINITY) = %+f\n",   atan(+INFINITY));   /* +pi/2 */
    printf("atan(-INFINITY) = %+f\n",   atan(-INFINITY));   /* -pi/2 */
    printf("atan(NAN)       = %.1f\n",  atan(NAN));
 
    return 0;
}

Possible output:

atan(+1.0) = +0.785398
atan(-1.0) = -0.785398
 
atan(+0.0)      = +0.0
atan(-0.0)      = -0.0
atan(+INFINITY) = +1.570796
atan(-INFINITY) = -1.570796
atan(NAN)       = nan

[edit] See also

arc tangent, using signs to determine quadrants
(function) [edit]
computes arc sine (arcsin(x))
(function) [edit]
computes arc cosine (arccos(x))
(function) [edit]
computes tangent (tan(x))
(function) [edit]