Close

Java - Math.atan() Examples

Java Java API 


Class:

java.lang.Math

java.lang.Objectjava.lang.Objectjava.lang.Mathjava.lang.MathLogicBig

Method:

public static double atan(double a)

Returns the arc tangent of a value; the returned angle is in the range -pi/2 through pi/2.

Parameters:
a - the value whose arc tangent is to be returned.
Returns:
the arc tangent of the argument.


Examples


package com.logicbig.example.math;

public class AtanExample {

public static void main(String... args) {
findArcTangent(0);
findArcTangent(0.5774);
findArcTangent(1);
findArcTangent(1.732);
findArcTangent(Double.MAX_VALUE);
}

private static void findArcTangent(double value) {
double tanValue = Math.atan(value);
double degree = Math.toDegrees(tanValue);
System.out.printf("ArcTangent of %s = %.2f degrees%n", value, degree);
}
}

Output

ArcTangent of 0.0 = 0.00 degrees
ArcTangent of 0.5774 = 30.00 degrees
ArcTangent of 1.0 = 45.00 degrees
ArcTangent of 1.732 = 60.00 degrees
ArcTangent of 1.7976931348623157E308 = 90.00 degrees




See Also