GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Java Tutorial
  • Advanced Java
  • Interview Questions
  • Exercises
  • Examples
  • Quizzes
  • Projects
  • Cheatsheet
  • DSA in Java
  • Java Collection
  • Introduction3 min read
  • Variables2 min read
  • Data Types7 min read
  • Operators7 min read

This view

  • Original page
  • New address

GeezerVison is showing www.geeksforgeeks.org — Java Math asin() Method - GeeksforGeeks

geeksforgeeks
search icon
  • Courses
  • Tutorials
  • Interview Prep
  • Java Tutorial
  • Advanced Java
  • Interview Questions
  • Exercises
  • Examples
  • Quizzes
  • Projects
  • Cheatsheet
  • DSA in Java
  • Java Collection

Java Math asin() Method

Last Updated : 7 May, 2025

The asin() method of java.lang.Math class, computes the arc sine also called as an inverse of a sine of a given value. This method is useful when we have the sine of an angle and we need to find the angle. This method returns the arc sine of an angle in between -pi/2 and pi/2.

  • If the argument is NaN or its absolute value is greater than 1, then the result is NaN.
  • If the argument is zero, then the result is a zero with the same sign as the argument.

Syntax of Math asin() Method

public static double asin(double angle)

  • Parameter: angle: The value whose arc sine is to be returned.
  • Return: The arc sine of the argument in radians.
  • Valid Range: -1.0 <= angle <= 1.0 and the values outside this range will result NaN.

Important Points:

  • The valid input returns a real angle between -pi/2 and pi/2.
  • The zero input produces 0.0.
  • asin(1.0) is equals to pi/2 and asin(-1.0) is equals to -pi/2.
  • The invalid input returns NaN to indicate an error.

Examples of Java Math asin() Method

Example 1: In this example, we will try to handle out of valid range values.

Java
// Java program to handle out-of-range input
public class Geeks {
    
    public static void main(String[] args) {
        
        double i = 2.0; 
        System.out.println("asin(" + i + ") = " + Math.asin(i));
    }
}

Output
asin(2.0) = NaN

Explanation: Here, 2.0 is not a valid sine value, so asin() indicates the error with NaN.


Example 2: In this example, we will convert the degrees to radians before asin().

Java
// Java program to convert degrees to radians
public class Geeks {
    
    public static void main(String[] args) {
        
        double degrees = 30.0;                    
        double radians = Math.toRadians(degrees); 
        System.out.println("asin(sin30°) in radians: "
            + Math.asin(Math.sin(radians)));
    }
}

Output
asin(sin30°) in radians: 0.5235987755982988


Example 3: In this example, we will take multiple inputs in one array.

Java
// Java program to loop through multiple values
public class Geeks {
    
    public static void main(String[] args) {
        
        double[] values = {1.0, 0.0, -1.0, 0.5};
        for (double v : values) {
            System.out.printf("asin(%.1f): %.4f rad\n", v, Math.asin(v));
        }
    }
}

Output
asin(1.0): 1.5708 rad
asin(0.0): 0.0000 rad
asin(-1.0): -1.5708 rad
asin(0.5): 0.5236 rad
Comment

Explore

    Basics
    • Introduction3 min read
    • Variables2 min read
    • Data Types7 min read
    • Operators7 min read
    • Decision Making5 min read
    • Methods7 min read
    • Arrays7 min read
    • Strings5 min read
    OOP & Interface
    • Introduction6 min read
    • Constructors6 min read
    • Encapsulation3 min read
    • Inheritance8 min read
    • Polymorphism5 min read
    • Abstraction5 min read
    • Interfaces8 min read
    Collections
    • Collection class9 min read
    • Collection Interface5 min read
    • List Interface8 min read
    • Set Interface5 min read
    • Queue Interface5 min read
    • Map Interface in Java6 min read
    • Iterator4 min read
    Advance Java Concepts
    • Exception handling6 min read
    • Java Multithreading Tutorial3 min read
    • Synchronization in Java9 min read
    • File handling6 min read
    • Method References3 min read
    • Java 8 Stream Tutorial7 min read
    • Memory Management4 min read
    • Garbage Collection in Java6 min read
    • Networking6 min read
    • JDBC5 min read
    Practice Java
    • Interview Questions15+ min read
    • Programs6 min read
    • Practice Problems5 min read
    • Quiz1 min read
    • Project Ideas15+ min read
    Courses
    • Java Backend Course2 min read
    • Placement 360 Course2 min read
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.