Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

C library function - atan()

C library function - atan()

C Standard Library - <math.h> C Standard Library -

Description

atan() is a function in the C standard library is a function used to compute the arctangent of a number (also known as the inverse tangent function among inverse trigonometric functions). The function accepts a real number and returns the arctangent of the value, in radians.

atan() The function computes the arctangent of a given value and is a common tool for handling inverse trigonometric operations.atan2() The function is better suited for computing the arctangent of y/x and can correctly handle angles in different quadrants. In mathematical calculations, choosing and using these two functions appropriately yields accurate results.

Declaration

The following is the declaration of the atan() function.



#include 



double atan(double x);

float atanf(float x);

long double atanl(long double x);

Parameters

Return Value

Example

The following example demonstrates the use of the atan() function.

Example

#include

#include

#define PI 3.14159265

int

main

(

)

{

   

double

x

,

ret

,

val

;

   x

=

1.0

;

   val

=

180.0

/

PI

;

   ret

=

atan

(

x

)

val

;

   

printf

(

The arctangent of %lf is %lf degrees

,

x

,

ret

)

;

   

   

return

(

0

)

;

}

Let's compile and run the above program, which will produce the following result:



1.000000 的反正切是 45.000000 度

C Standard Library - <math.h> C Standard Library -