Related Tags

d
math
atan
communitycreator

# What is atan() in D?

harris910

The atan() function, also called the arc tangent function, returns the inverse tangent of a number. To be more specific, it returns the inverse tangent of a number in radians.

Figure 1 shows the mathematical representation of the atan() function.

Figure 1: Mathematical representation of inverse tangent function

Note: std.math is required for this function.

To convert radians to degrees, use the following formula:

degrees = radians * ( 180.0 / PI )


### Syntax

The syntax of the function is as follows:

atan(number)
//number can be real, float, or double.


### Parameter

This function requires a number as a parameter.

### Return value

atan() returns the inverse tangent of a number (radians) that is sent as a parameter.

The return value lies in the interval [-PI/2, PI/2] radians.

### Code

The code below shows the use of the atan() function in D.

import core.stdc.stdio;
import std.stdio;
import std.math;

int main() {
writeln("The value of atan(0.5): ",atan(0.5) ," Radians");

writeln("The value of atan(-0.5): ",atan(-0.5) ," Radians");

//applying atan() and then converting the result in radians to degrees
// PI = 3.14159265
double result=atan(1.0) * (180.0 / PI);
writeln("The value of atan(1.0): ",result," Degrees");

return 0;
}

RELATED TAGS

d
math
atan
communitycreator

CONTRIBUTOR

harris910
RELATED COURSES

View all Courses

Keep Exploring

Learn in-demand tech skills in half the time