# C++ cmath atan,atanf and atanl function

The C++ cmath atan,atanf and atanl function computes the arc tangent of the given value.The declaration of the functions are given below:

The first function ‘float atan(float x)’ is called if the argument is float type.

The second ‘double atan(double x)’ is called, if the argument is double type.

The third function is called if the argument is long double type.

The 4th and 5th function are discussed in detail below.

Some points to note:

i)-There is no restriction on the range of values that can be used as an argument.

ii)-The returned value is in the interval [-π/2,+π/2] radians.

iii)-The second version is the default version that is called when atan is called wihtout any specific argument type.

iv)-When the argument passed is int type the default version is called.

Note arc tangent means inverse of tangent,so atan(x) is same as tan-1(x).

Include <typeinfo> to call the ‘typeid()’ function. This function checks the type of the argument.

```cout&lt;&lt; atan(0.23) &lt;&lt; endl //calls atan(double)
&lt;&lt; atan(9090);

cout&lt;&lt; typeid( atan(0.23) ).name( ) ;
```

Output,

0.226068
1.57069
d

The ‘d’ in the output means ‘double’.

## C++ cmath atanf function

The first version i.e. float atan(float x) function is similar to the atanf function. Both these functions accpet float as the argument type and the return type. The ‘f’ in atanf means float which signify the type of the argument and the return value.

```float f=0.2;

cout&lt;&lt; atan(f) &lt;&lt; endl
&lt;&lt; atanf(0.2) &lt;&lt; endl ;

cout&lt;&lt; typeid( atan(f) ).name( ) &lt;&lt; endl
&lt;&lt; typeid( atanf(0) ).name( ) &lt;&lt; endl ;
```

Output

0.197396
0
f
f

###### Property of acosf

If we pass an argument type other than the float type, say double type to ‘atanf’, then this function will always convert the argument type to the float type first and then compute the arc tangent of the float argument value. The return type is also float type. In other words, this function always constrain the parameter type and the return type to the the float type.

```cout&lt;&lt; atanf( (double)40 ) ;//calls atanf(float)

cout&lt;&lt;&quot;\nReturn type:&quot;&lt;&lt; typeid( atanf( (double)40) ).name( ) ;
```

Output,

1.5458
Return type:f

## C++ cmath atanl function

The atanl function is similar to the 3rd version atan function. Both the functions have long double as the argument and the return type. The argument and the return type in atanl function is specified by the character ‘l’ which stands for long double.

```long double ld=0.22 ;

cout&lt;&lt; atan(ld) &lt;&lt; endl
&lt;&lt; atanl(0.22) &lt;&lt; endl ;

cout&lt;&lt; typeid( atan(ld) ).name( ) &lt;&lt; endl
&lt;&lt; typeid( atanl(0.22) ).name( ) &lt;&lt; endl ;
```

Output

0.21655
0.21655
e
e

###### Property of acosl

If we pass an argument type other than the long double type, say double type to ‘atanl’, then this function will always convert the argument type to the long double type first, and then compute the arc tangent of the long double argument value. The return type is also long double type. In other words, this function always constrain the parameter type and the return type to the the long double type.

```cout&lt;&lt; atanl( (double)40 ) ;//calls atanl(long double)

cout&lt;&lt;&quot;\nReturn type:&quot;&lt;&lt; typeid( atanl( (double)40) ).name( ) ;
```

Output,

1.5458
Return type:e

The value returned by atan is in radian.You can convert it to degree by using the simple conversion rule.

The relation between radian and degree is shown below,

```cout&lt;&lt; “atan(0.5°)=” &lt;&lt; ( atan(1)*180 )/3.141592 &lt;&lt; “°” &lt;&lt; endl ;