C library functions -atan()
Description
atan()is the C standard library<math.h>A function used to calculate the arctangent of a number (also known as the inverse tangent function among inverse trigonometric functions). This function accepts a real number and returns the arctangent of that value, in radians.
atan()The function is used to calculate the arctangent of a given value, and is a common tool for handling inverse operations of trigonometric functions.atan2()The function is more suitable for calculating the arctangent of y/x and can correctly handle angles in different quadrants. In mathematical calculations, selecting and using these two functions appropriately can yield accurate results.
Declaration
Below is the declaration of the atan() function.
#include <math.h> double atan(double x); float atanf(float x); long double atanl(long double x);
Parameter
- x-- floating-point value.
Return Value
- return
xThe arctangent of, in radians. The return value ranges from [-π/2, π/2].
Example
The following example demonstrates the usage of the atan() function.
Example
#include <math.h>
#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 us compile and run the above program, which will produce the following results:
1.000000 的反正切是 45.000000 度other extensions