Get the arc sine of an angle in Java


To get the arc sine of a given value in Java, we use the java.lang.Math.asin() method. The asin() method accepts a double value whose angle needs to be computed. The range of the angle returned lies in the range -pi/2 to pi/2. If the argument is NaN, then the result is NaN.

When the argument is zero, then the output is a zero with the same sign as the argument.

Declaration − The java.lang.Math.asin() method is declared as follows−

public static double asin(double a)

where a is the value whose arc sine is computed.

Let us see a program to get the arc sine of a given value in Java.

Example

 Live Demo

import java.lang.Math;
public class Example {
   public static void main(String[] args) {
      // get two double numbers in degrees
      double x = Math.sqrt(3)/2;
      double y = 0.5;
      // computing and displaying the arc sine of these doubles
      System.out.println("Arc sine of " + x + " = " + Math.asin(x));
      System.out.println("Arc sine of " + y + " = " + Math.asin(y));
   }
}

Output

Arc sine of 0.8660254037844386 = 1.0471975511965976
Arc sine of 0.5 = 0.5235987755982989

Updated on: 26-Jun-2020

144 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements