Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

java
communitycreator
math.atan()
math

# What is Math.atan() in Java? Tarun Telang

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Java has a built-in Math class, defined in the java.lang package, which contains important functions to perform basic mathematical operations.

The class has the atan() method, which is used to compute an $\arctan$ or $\tan^{-1}$ (pronounced as “inverse tangent”) of the specified value.

If $tan(\theta)$ is x then $tan^{-1}$(x) or $arctan(x)$ is $\theta$.

## Method definition

public  static double atan(double value);


### Parameter

value represents the double value for which we have to find the arc tangent.

### Return value

The function returns the double value corresponding to the arctangent of the value. The returned value will lie within the range $\pi/2$ to $-\pi/2$.

Note: Math.PI is a constant equivalent to $\pi$ in Mathematics.

If the value is infinity or NaNnot a number, then the returned value is NaN.

Note: To convert an angle measured in radians to an equivalent angle measured in degrees and vice versa, you can use the built-in Math.toDegrees(double angle_in_randians) and Math.toRadians(double angle_in_degrees) methods.

## Code

class HelloWorld {    public static void main( String args[] ) {        double result = Math.atan(1);        System.out.println("atan(1) = " + result);        result = Math.atan(0);        System.out.println("atan(0) = " +  result);        result = Math.atan(0.48);        System.out.println("atan(0.48) = " + result);        result = Math.atan(0.66);        System.out.println("atan(O.66) = " + result);        result = Math.atan(0.8);        System.out.println("atan(0.8) = " + result);        result = Math.atan(1);        System.out.println("atan(1) = " + result);        result = Math.atan(Double.NaN);        System.out.println("atan(NaN) = " + result);        result = Math.atan(Double.POSITIVE_INFINITY);        System.out.println("atan(∞) = " + result);    }}
Example code for Math.atan() in Java

RELATED TAGS

java
communitycreator
math.atan()
math

CONTRIBUTOR Tarun Telang

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Learn in-demand tech skills in half the time 