What is Math.asin() in Java?

Java has a built-in Math class, defined in the java.lang package, which contains important functions to perform basic mathematical operations. The class has the asin() method, which is used to compute an arcsin\arcsin or the sin1sin^{-1} (pronounced inverse sin) of the specified value.

If sin(θ)sin(\theta) is x then sin1sin^{-1}(x) or arcsin(x)\arcsin(x) is θ\theta.

Method definition

public  static double asin(double value);

Parameter

This function has one parameter, value, which represents the double value for which we have to find the arcsin\arcsin.

Return value

The function returns the double value corresponding to the arcsin\arcsin of the value. The returned value will lie within the range π/2\pi/2 to π/2-\pi/2.

Note: Math.PI is a constant equivalent to π\pi in mathematics.

If the value of value is infinity or NaNnot a number, then the returned value is NaN.

Note: To convert an angle measured in radians to an equivalent angle measured in degrees and vice versa, we can use the built-in Math.toDegrees(double angle_in_randians) and Math.toRadians(double angle_in_degrees) methods.

Code

class HelloWorld {
public static void main( String args[] ) {
double result = Math.asin(1);
System.out.println("asin(1) = " + result);
result = Math.asin(0);
System.out.println("asin(0) = " + result);
result = Math.asin(0.48);
System.out.println("asin(0.48) = " + result);
result = Math.asin(0.66);
System.out.println("asin(O.66) = " + result);
result = Math.asin(0.8);
System.out.println("asin(0.8) = " + result);
result = Math.asin(1);
System.out.println("asin(1) = " + result);
result = Math.asin(Double.NaN);
System.out.println("asin(NaN) = " + result);
result = Math.asin(Double.POSITIVE_INFINITY);
System.out.println("asin(∞) = " + result);
}
}

Free Resources