Java Math asin() Function

asin function

Java Math Class

Java Math class provides several basic and advance methods to perform different operations on math calculations like max(), min(), sin(), round(), ceil(), floor(), asin() etc.
The java.lang.Math class contains various methods for performing basic numeric operations

Here, in the page we will discuss about the asin() Method in java.

Java asin() Function :

Java Collection contains Math class and The class Math contains methods for performing basic and advance numeric operations such as the exponential, logarithm, square root, and trigonometric functions.
The Java asin() Function returns the arc sine of a given input. arc sine is also known as inverse of sine.
The given input should always be less than 1. if the given input is NaN or lesser than 1 then the output will be NaN.

Syntax:

Math.asin(number);

Definition of Parameters:

Return Type :

clear() Function in ArrayList

clone() Function in ArrayList

add() Function in ArrayList

addall() Function in ArrayList

Example For Numbers in Valid Range:

Run
import java.util.*;

public class Main{
    public static void main(String[] args){
        double a = 0;
        double b = 0.1;
        double c = 1;
        
        // Printing asin value for 0
        System.out.println("asin value of 0 is : " + Math.asin(a));
        
        // Printing asin value for range between 0 and 1
        System.out.println("asin value for number in range is : " + Math.asin(b));
        
        // Printing asin value for 1
        System.out.println("asin value for 1 is : " + Math.asin(c));
    }
}
Output:

asin value of 0 is : 0.0
asin value for number in range is : 0.1001674211615598
asin value for 1 is : 1.5707963267948966

In the above Example, We had taken examples for double values with range includes 0 to 1

Example for Out of Range Numbers:

Run
import java.util.*;

public class Main{
    public static void main(String[] args){
        double a = 10;
        double b = 2.5;
        double c = 1.1;
        
        // Printing asin values for out of range values
        System.out.println(Math.asin(a));
        System.out.println(Math.asin(b));
        System.out.println(Math.asin(c));
    }
}
Output:

NaN
NaN
NaN

In the above Example, We had taken out of range numbers for which we will be getting NaN output.

Example for Negative and NaN Value Number :

Run
import java.util.*;

public class Main{
    public static void main(String[] args){
        double a = -10;
        double b = -2;
        
        // Printing asin values for Negative Numbers
        System.out.println(Math.asin(a));
        System.out.println(Math.asin(b));
    }
}
Output:

NaN
NaN

In the above Example, We had taken negative value which gives NaN output.

Prime Course Trailer

Related Banners

Get PrepInsta Prime & get Access to all 200+ courses offered by PrepInsta in One Subscription

Get over 200+ course One Subscription

Courses like AI/ML, Cloud Computing, Ethical Hacking, C, C++, Java, Python, DSA (All Languages), Competitive Coding (All Languages), TCS, Infosys, Wipro, Amazon, DBMS, SQL and others

Checkout list of all the video courses in PrepInsta Prime Subscription

Checkout list of all the video courses in PrepInsta Prime Subscription