Java Math asin() Method
The asin() method of Math class computes the trigonometric Arc Sine (inverse of sine ) of an angle. The value returned is between -pi/2 to pi/2.
Syntax:
public static double asin(double a)
Parameters:
The parameter ‘a’ represents the value whose arc sine is to be determined.
Return Value:
The asin() method returns the arc sine of the argument .
- It returns NaN, if we pass a NaN or absolute argument greater than 1.
- If we pass zero as an argument, it will return zero with the same sign as the argument.
Example 1:
public class JavaMathAsinExample1 {
public static void main(String[] args) {
double a=1/2;
//return the arc sine value for a
System.out.println("Arc sin value : "+Math.asin(a));
}
}
Output:
Arc sin value : 0.0
Example 2:
public class JavaMathAsinExample2 {
public static void main(String[] args) {
//return the arc sine value for Double.MIN_VALUE
double a=Double.MIN_VALUE;
System.out.println("Arc sine value for "+a+" = "+Math.asin(a));
}
}
Output:
Arc sine value for 4.9E-324 = 4.9E-324
Example 3:
public class JavaMathAsinExample3 {
public static void main(String[] args) {
// Math.PI value is 3.414 that is greater than 1
double x = Math.PI;
System.out.println("Arc sine value for "+x+" = "+Math.asin(x));
}
}
Output:
Arc sine value for 3.141592653589793 = NaN
Example 4:
public class JavaMathAsinExample4 {
public static void main(String[] args) {
double x= 7.0987;
double y= Math.toRadians(x);
System.out.println(Math.asin(y));
}
}
Output:
0.1242148667016853
