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 or (pronounced as “inverse tangent”) of the specified value.
If is x then (x) or is .
public static double atan(double value);
value
represents the double value for which we have to find the arc tangent.
The function returns the double value corresponding to the arctangent of the value
. The returned value will lie within the range to .
Note:
Math.PI
is a constant equivalent to in Mathematics.
If the value
is infinity or
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)
andMath.toRadians(double angle_in_degrees)
methods.
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);}}