Java Math - atan() Method
The java.lang.Math.atan() method returns arc tangent of a value. The returned 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 a)
Parameters
a |
Specify the value whose arc tangent is to be returned. |
Return Value
Returns the arc tangent of the argument.
Exception
NA.
Example:
In the example below, atan() method is used to find out the arc tangent of the given values.
import java.lang.*; 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.lang - Math