Home » Java programming language

Java StrictMath atan() method with example

StrictMath Class atan() method: Here, we are going to learn about the atan() method of StrictMath Class with its syntax and example.
Submitted by Preeti Jain, on December 25, 2019

StrictMath Class atan() method

  • atan() method is available in java.lang package.
  • atan() method is used to return the arc tangent of an angle of the given parameter in the method. Here, atan stands for arc tangent of an angle.
  • atan() method is a static method so it is accessible with the class name and if we try to access the method with the class object then we will not get an error.
  • In this method, we pass only radians type argument (i.e. First we convert given argument in radians by using toRadians() method of Math class then after we will pass the same variable in atan() method).
  • atan() method does not throw any exception.
  • In this method, the meaning of arc tangent is the inverse or reverse tangent of the given argument.
  • The range of atan() lies – PI/2 through PI/2.

Syntax:

    public static double atan(double d);

Parameter(s):

  • double d – represents a double type value whose arc tangent value to be found.

Return value:

The return type of this method is double – it returns the arc tangent of given angle.

Note:

  • If we pass NaN as an argument, method returns the same value (NaN).
  • If we pass zero (0), method returns the same value with the same sign.

Example:

// Java program to demonstrate the example of  
// atan(double d) method of StrictMath Class.

public class Atan {
    public static void main(String[] args) {
        // variable declarations
        double d1 = -0.0;
        double d2 = Math.PI / 2;

        // Display previous value of d1 and d2
        System.out.println("d1: " + d1);
        System.out.println("d2: " + d2);

        // Here , we will get (-0.0) because we are 
        // passing parameter whose absolute value is -0.0
        System.out.println("StrictMath.atan(d1): " + StrictMath.atan(d1));

        // By using toRadians() method is used to 
        // convert absolute to radians
        d2 = StrictMath.toRadians(d2);

        // Display the value of d2 in radians form
        System.out.println("StrictMath.toRadians(d2): " + d2);

        // Here we will find arc tangent of d2 by 
        // using atan() method
        System.out.println("StrictMath.atan(d2): " + StrictMath.atan(d2));
    }
}

Output

d1: -0.0
d2: 1.5707963267948966
StrictMath.atan(d1): -0.0
StrictMath.toRadians(d2): 0.027415567780803774
StrictMath.atan(d2): 0.0274087022410345






Comments and Discussions

Ad: Are you a blogger? Join our Blogging forum.






Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing
» Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com some rights reserved.