Facebook Page Twitter Page LinkedIn Page
× C++ Standard Library C++ STL Library


The C++ cmath asin() function is used to return arc sine of a value. The return value will be in the range -𝜋/2 through 𝜋/2.

Note: asin() is the inverse of sin().

Syntax

double asin (double x);
float asin (float x);
long double asin (long double x);
double asin (double x);
float asin (float x);
long double asin (long double x);
// additional overloads for integral types
double asin (T x);  

Parameters

x Specify the value in range [-1, 1].

Return Value

Returns the arc sine of the value.
If the x is not in the range of [-1, 1], domain error occurs.

Example:

In the below example, asin() function is used to find out the arc sine of a given value.

#include <iostream>
#include <cmath>

using namespace std;
 
int main (){
  cout<<asin(0.5)<<"\n";
  cout<<asin(1)<<"\n";
  cout<<asin(2)<<"\n";
  return 0;
}

The output of the above code will be:

0.523599
1.5708
nan

❮ C++ <cmath> Library