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 or the (pronounced inverse sin) of the specified value.
If is x then (x) or is .
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 .
Return value
The function returns the double value corresponding to the of the value. The returned value will lie within the range to .
Note:
Math.PIis a constant equivalent to in mathematics.
If the value of value is infinity or 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)andMath.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);}}