# Get the arc tangent of a given value in Java

Java 8Object Oriented ProgrammingProgramming

#### Complete Java Programming Fundamentals With Sample Projects

98 Lectures 7.5 hours

#### Get your Java dream job! Beginners interview preparation

85 Lectures 6 hours

#### Core Java bootcamp program with Hands on practice

Featured

99 Lectures 17 hours

To get the arc tangent of a given value in Java, we use the java.lang.Math.atan() method. The atan() method accepts a double value whose angle needs to be computed. The range of the angle returned lies in the range -pi/2 to pi/2. If the argument is NaN, then the result is NaN.

When the argument is zero, then the output is a zero with the same sign as the argument.

Declaration −The java.lang.Math.atan() method is declared as follows −

public static double atan(double a)

where a is the value whose arc tangent is computed.

Let us see a program to get the arc tangent of a given value in Java.

## Example

import java.lang.Math;
public class Example {
public static void main(String[] args) {
// get two double numbers in degrees
double x = Math.sqrt(3);
double y = 1;
// computing and displaying the arc tangent of these doubles
System.out.println(“Arc tangent of " + x + " = " + Math.atan(x));
System.out.println("Arc tangent of " + y + " = " + Math.atan(y));
}
}

## Output

Arc tangent of 1.7320508075688772 = 1.0471975511965976
Arc tangent of 1.0 = 0.7853981633974483
Updated on 26-Jun-2020 09:51:29