Home » Java programming language

Java StrictMath asin() method with example

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

StrictMath Class asin() method

  • asin() method is available in java.lang package.
  • asin() method is used to return the arc sine of the given parameter in the method. Here, asin stands for arc sine of an angle.
  • asin() 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 asin() method).
  • This method does not throw any exception.
  • In this method, the meaning of arcsine is the inverse or reverse sine of the given argument.
  • The range of asin() lies – PI/2 through PI/2.

Syntax:

    public static double asin(double d);

Parameter(s):

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

Return value:

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

Note:

  • If we pass NaN as an argument, method returns the same value (NaN).
  • If we pass an argument whose absolute value is greater than 1, method returns NaN.

Example:

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

public class Asin {
    public static void main(String[] args) {
        // variable declarations
        double a1 = 100;
        double a2 = Math.PI / 2;
        double a3 = 0;

        // Display previous value of a1, a2 and a3
        System.out.println("a1: " + a1);
        System.out.println("a2: " + a2);
        System.out.println("a3: " + a3);

        // Here , we will get NaN because we are 
        // passing parameter whose absolute value is 
        // greater than 1
        System.out.println("StrictMath.asin(a1): " + StrictMath.asin(a1));

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

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

        // Here we will find arc sine of a2 by using asin() method
        System.out.println("StrictMath.asin(a2): " + StrictMath.asin(a2));

        // Here , we will get 0 because we are passing 
        // parameter whose absolute value is 0
        System.out.println("StrictMath.asin(a3): " + StrictMath.asin(a3));
    }
}

Output

a1: 100.0
a2: 1.5707963267948966
a3: 0.0
StrictMath.asin(a1): NaN
StrictMath.toRadians(a2): 0.027415567780803774
StrictMath.asin(a2): 0.02741900326072046
StrictMath.asin(a3): 0.0


Comments and Discussions!

Load comments ↻





Copyright © 2024 www.includehelp.com. All rights reserved.