Facebook Page Twitter Page LinkedIn Page
× Java Tutorial Java Advanced Java Resources


The Java Math atan() method is used to return arc tangent of a value. The return value will be in the range -𝜋/2 through 𝜋/2. In special cases it returns the following:

  • If the argument is NaN, then the result is NaN.
  • If the argument is zero, then the result is a zero with the same sign as the argument.

Note: atan() is the inverse of tan().

Syntax

public static double atan(double arg)

Parameters

arg Specify the value.

Return Value

Returns the arc tangent of the value.

Exception

NA.

Example:

In the below example, atan() method is used to find out the arc tangent of a given value.

public class MyClass {
 public static void main(String[] args) {
  System.out.println(Math.atan(0.5));   
  System.out.println(Math.atan(1));
  System.out.println(Math.atan(2));     
 }
}

The output of the above code will be:

0.4636476090008061
0.7853981633974483
1.1071487177940904

❮ Java Math Methods