ASIN() and ACOS() Function in MySQL
1. ASIN() Function :
ASIN() function in MySQL is used to return the arc sine of any number in the range[ -1, 1] . It Returns NULL if the number is not in the range -1 to 1.
Syntax :
Attention reader! Don’t stop learning now. Learn SQL for interviews using SQL Course by GeeksforGeeks.
ASIN(X)
Parameter :
ASIN() function accepts one parameter as mentioned above and described below.
- X –A number whose arc sine we want to calculate .It should be in the range [-1, 1].
Returns :
It returns the arc sine of given number x.
Example-1 :
Arc sine of 1 using ASIN() function.
SELECT ASIN(1) AS Asin_Val ;
Output :
| Asin_Val |
|---|
| 1.5707963267948966 |
Example-2 :
Arc sine of a number in the range(0, 1) using ASIN() function.
SELECT ASIN(0.25) AS Asin_Val;
Output :
| Asin_Val |
|---|
| 0.25268025514207865 |
Example-3 :
Arc sine of a number in the range(0, -1) using ASIN() function.
SELECT ASIN(-0.35) AS Asin_Val;
Output :
| Asin_Val |
| -0.35757110364551026 |
Example-4 :
Arc sine of a number which is not in the range[0, -1] using ASIN() function.
SELECT ASIN(2.75) AS Asin_Val ;
Output :
| Asin_Val |
|---|
| NULL |
Example-5 :
Arc sine value of a numeric column in a table.
Table -Number
| X |
|---|
| -2 |
| -1 |
| -0.50 |
| 0 |
| 0.50 |
| 1 |
| 2 |
SELECT X, ASIN(X) AS ArcSin_X FROM Number ;
Output :
| X | ArcSin_X |
|---|---|
| -5 | NULL |
| -1 | -1.5707963267948966 |
| -0.50 | -0.5235987755982989 |
| 0 | 0 |
| 0.50 | 0.5235987755982989 |
| 1 | 1.5707963267948966 |
| 2 | NULL |
2. ACOS() function :
ACOS() function in MySQL is used to return the arc cosine of any number in the range[ -1, 1].It Returns NULL if the number is not in the range -1 to 1.
Syntax :
ACOS(X)
Parameter :
ACOS(X) function accepts one parameter and In ACOS(X) function X is the parameter. Let’s understand with the help of examples.
- X –A number whose arc cosine we want to calculate .It should be in the range [-1, 1].
Returns :
It returns the arc cosine of given number x.
Example-1 :
Arc cosine of 1 using ACOS() function.
SELECT ACOS(1) AS Acos_Val;
Output :
| Acos_Val |
|---|
| 0 |
Example-2 :
Arc cosine of a number in the range(0, 1) using ACOS() function.
SELECT ACOS(0.75) AS Acos_Val;
Output :
| Acos_Val |
|---|
| 0.7227342478134157 |
Example-3 :
Arc cosine of a number in the range(0, -1) using ACOS() function.
SELECT ACOS(-0.75) AS Acos_Val ;
Output :
| Acos_Val |
|---|
| 2.4188584057763776 |
Example-4 :
Arc cosine of a number which is not in the range[0, -1] using ACOS() function.
SELECT ACOS(2.75) AS Acos_Val;
Output :
| Acos_Val |
|---|
| NULL |
Example-5 :
Arc cosine value of a numeric column in a table.
Table -Number
| X |
|---|
| -5 |
| -1 |
| -0.50 |
| 0 |
| 0.50 |
| 1 |
| 2 |
SELECT X, ACOS(X) AS Acos_Val FROM Number;
Output :
| X | Acos_Val |
|---|---|
| -5 | NULL |
| -1 | 3.141592653589793 |
| -0.50 | 2.0943951023931957 |
| 0 | 1.5707963267948966 |
| 0.50 | 1.0471975511965979 |
| 1 | 0 |
| 2 | NULL |


