Thursday, October 16, 2025
HomeLanguagesJavaJava atan() method with Examples

Java atan() method with Examples

The java.lang.Math.atan() returns the arc tangent of an angle in between -pi/2 through pi/2. If the argument is NaN, then the result is NaN.

Note:If the argument is zero, then the result is a zero with the same sign as the argument.

Syntax :

public static double atan(double a)
Parameter :
a : the value whose arc tangent is to be returned.
Return :
This method returns the arc tangent of the argument.

Example :To show working of java.lang.Math.atan() method.




// Java program to demonstrate working
// of java.lang.Math.atan() method
import java.lang.Math;
  
class Gfg {
  
    // driver code
    public static void main(String args[])
    {
        double a = Math.PI;
  
        System.out.println(Math.atan(a));
  
        double c = 344.0;
        double d = 0.0;
        double e = -0.0;
        double f = 1.5;
  
        System.out.println(Math.atan(c));
  
        // Input positive zero
        // Output positive zero
        System.out.println(Math.atan(d));
  
        // Input negative zero
        // Output negative zero
        System.out.println(Math.atan(e));
  
        System.out.println(Math.atan(f));
    }
}


Output:

1.2626272556789115
1.5678893582391513
0.0
-0.0
0.982793723247329
RELATED ARTICLES

Most Popular

Dominic
32361 POSTS0 COMMENTS
Milvus
88 POSTS0 COMMENTS
Nango Kala
6728 POSTS0 COMMENTS
Nicole Veronica
11892 POSTS0 COMMENTS
Nokonwaba Nkukhwana
11954 POSTS0 COMMENTS
Shaida Kate Naidoo
6852 POSTS0 COMMENTS
Ted Musemwa
7113 POSTS0 COMMENTS
Thapelo Manthata
6805 POSTS0 COMMENTS
Umr Jansen
6801 POSTS0 COMMENTS