C++ Math asin()

Last Updated : 16 May 2026

Math asin() Function

In C++, the asin() function is defined in the <cmath> or <math.h> header file and is used to calculate the inverse sine (arc sine) of a given value. The inverse sine of a number is the angle whose sine is equal to that number, and the returned angle is expressed in radians.

The input value for the asin() function must be within the range -1 to 1. If the value is outside this range, the function returns NaN (Not a Number). The asin() function is widely used in trigonometry, geometry, graphics programming, and scientific calculations.

asin(x) = sin-1x

Syntax

It has the following syntax:

Note: If the value passed is an integer type, then it is cast to double.

Parameter

x: The value whose inverse sine is to be calculated

Return value

ParameterReturn value
-1≤x≤1-∏/2,∏/2
x<-1 or x>1Not a Number

Examples of Math asin() Function

Here, we are going to discuss several examples to demonstrate the Math asin() Function

Example 1: Calculate the Inverse Sine of Zero Using asin()

This example demonstrates how to calculate the inverse sine when the input value is zero using the asin() function.

Output:

Value of Sine is :0
Inverse of Sine is :0   

Explanation:

In this example, asin() function calculates the inverse sine of a number when the value of x is zero.

Example 2: Calculate the Inverse Sine for a Value Greater Than 1

This example demonstrates how the asin() function behaves when the input value is greater than 1. Since the value is outside the valid range, the function returns NaN.

Output:

Value of Sine is :1
Inverse of Sine is :nan   

Explanation:

In this example, asin() function calculates the inverse sine of a number when the value of x is greater than 1.

Example 3: Calculate the Inverse Sine for an Invalid Negative Value

This example demonstrates how the asin() function behaves when the input value is outside the valid range less than -1. In such cases, the function returns NaN.

Output:

Value of Sine is : -0.978004
Inverse of Sine is :nan   

Explanation:

In this example, asin() function calculates the inverse sine of a number when the value of x is less than -1.