GeeksforGeeks App
Open App
Browser
Continue

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 :

`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 :

Example-2 : Arc sine of  a number in the range(0, 1)  using ASIN() function.

`SELECT ASIN(0.25) AS Asin_Val;`

Output :

Example-3 : Arc sine of  a number in the range(0, -1)  using ASIN() function.

`SELECT ASIN(-0.35) AS Asin_Val;`

Output :

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 :

Example-5 : Arc sine value of a numeric column in a table. Table -Number

`SELECT X, ASIN(X) AS ArcSin_X  FROM Number ;`

Output :

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 :

Example-2 : Arc cosine of a number in the range(0, 1) using ACOS() function.

`SELECT ACOS(0.75) AS Acos_Val;`

Output :

Example-3 : Arc cosine of  a number in the range(0, -1) using ACOS() function.

`SELECT ACOS(-0.75) AS Acos_Val ;`

Output :

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 :

Example-5 : Arc cosine value of a numeric column in a table. Table -Number

`SELECT X, ACOS(X) AS Acos_Val  FROM Number;`

Output :

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