Java Math asin() method with Example

The java.lang.Math.asin() returns the arc sine of an angle in between -pi/2 and pi/2. Arc sine is also called as an inverse of a sine.

  • If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
  • If the argument is zero, then the result is a zero with the same sign as the argument.

Syntax :

public static double asin(double angle)
Parameter :
angle : the value whose arc sine is to be returned.

Return :
This method returns the arc sine of the argument.



Example 1 : To show working of java.lang.Math.asin() method.

filter_none

edit
close

play_arrow

link
brightness_4
code

// Java program to demonstrate working
// of java.lang.Math.asin() method
import java.lang.Math;
 
class Gfg {
 
    // driver code
    public static void main(String args[])
    {
        double a = Math.PI;
 
        // Output is NaN, because Math.PI gives 3.141 value
        // greater than 1
        System.out.println(Math.asin(a));
 
        // convert Math.PI to radians
        double b = Math.toRadians(a);
 
        System.out.println(Math.asin(b));
 
        double c = 1.0;
        System.out.println(Math.asin(c));
 
        double d = 0.0;
        System.out.println(Math.asin(d));
 
        double e = -1.0;
        System.out.println(Math.asin(e));
 
        double f = 1.5;
 
        // value of f does not lie in between -1 and 1
        // so output is NaN
        System.out.println(Math.asin(f));
    }
}

chevron_right


Output:

NaN
0.054858647341251204
1.5707963267948966
0.0
-1.5707963267948966
NaN


My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.