Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

ASIN() and ACOS() Function in MySQL

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

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 :

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 :

XArcSin_X
-5NULL
-1-1.5707963267948966
-0.50-0.5235987755982989
00
0.500.5235987755982989
11.5707963267948966
2NULL

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 :

XAcos_Val
-5NULL
-13.141592653589793
-0.502.0943951023931957
01.5707963267948966
0.501.0471975511965979
10
2NULL

Both ASIN() and ACOS() functions can be used in SQL queries to perform mathematical calculations involving inverse trigonometric functions. Note that the output of these functions is in radians, not degrees. If you need to convert the result to degrees, you can use the DEGREES() function. 

Example:

SELECT DEGREES(ASIN(0.5));  -- returns 30 (This converts the angle in radians returned by ASIN() to degrees.)
My Personal Notes arrow_drop_up
Last Updated : 18 Apr, 2023
Like Article
Save Article
Similar Reads