How to get ARC Sine(ASIN) value in MySQL8?
With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. ASIN(number) helps in getting the angle, in radians, whose sine is provided as input number. Now let’s start with these.
ASIN(N) is a mathematical function. It returns the arc sine of a number, that is, the value whose sine is number. It returns NULL, if number is not in the range -1 to 1.
It returns Warning, if any string argument is passed.
MySQL ASIN() : Syntax
MySQL ASIN() : Parameter
Name, Required /Optional, Type, Description
number, Required, Double, It represents a valid number between -1.00 and 1.00.
MySQL ASIN() : Output
Return, Description
NULL, if the argument is NULL.
Double, It returns the arcsine of the input number.
MySQL ASIN() Available from : MySQL 4.0
ASIN() Example 1 : Very Basic example
Below is a very easy example. See the value when we pass the input as 0.
mysql> SELECT ASIN(0); +---------+ | ASIN(0) | +---------+ | 0 | +---------+ 1 row in set (0.21 sec)
See the value when we pass the input as 1.
mysql> SELECT ASIN(1); +--------------------+ | ASIN(1) | +--------------------+ | 1.5707963267948966 | +--------------------+ 1 row in set (0.06 sec)
See the value when we pass the input as -1.
mysql> SELECT ASIN(-1); +---------------------+ | ASIN(-1) | +---------------------+ | -1.5707963267948966 | +---------------------+ 1 row in set (0.01 sec)
ASIN() Example 2 :
Below are some more examples.
mysql> SELECT ASIN(.13256); +--------------------+ | ASIN(.13256) | +--------------------+ | 0.1329513298423883 | +--------------------+ 1 row in set (0.00 sec) mysql> SELECT ASIN(-.13256); +---------------------+ | ASIN(-.13256) | +---------------------+ | -0.1329513298423883 | +---------------------+ 1 row in set (0.00 sec)
ASIN() Example 3 : It will return Warning if any string argument is passed.
See the below example :
mysql> SELECT ASIN('TEST'); +--------------+ | ASIN('TEST') | +--------------+ | 0 | +--------------+ 1 row in set, 1 warning (0.00 sec) mysql> SHOW WARNINGS; +---------+------+------------------------------------------+ | Level | Code | Message | +---------+------+------------------------------------------+ | Warning | 1292 | Truncated incorrect DOUBLE value: 'TEST' | +---------+------+------------------------------------------+ 1 row in set (0.05 sec)
You can see the warning message with the help of the ‘SHOW WARNINGS’ command. Please refer above code for the same.
ASIN() Example 4 : NULL arguments
If the argument is NULL, it will return NULL. See the below example :
mysql> SELECT ASIN(NULL); +------------+ | ASIN(NULL) | +------------+ | NULL | +------------+ 1 row in set (0.05 sec)
If the input value is larger than the range of the input, then it also returns a NULL value. See the below example.
mysql> SELECT ASIN(2.5698); +--------------+ | ASIN(2.5698) | +--------------+ | NULL | +--------------+ 1 row in set (0.06 sec) mysql> SELECT ASIN(-72.5698); +----------------+ | ASIN(-72.5698) | +----------------+ | NULL | +----------------+ 1 row in set (0.00 sec)
ASIN() Example 5 : Using expressions
Here are some more examples to use the expression with the ASIN() function :
mysql> SELECT ASIN(.5); +--------------------+ | ASIN(.5) | +--------------------+ | 0.5235987755982989 | +--------------------+ 1 row in set (0.00 sec)
Now, we will get the same value if we pass the .5 as (.2+.3). See the below screen
mysql> SELECT ASIN(.2+.3); +--------------------+ | ASIN(.2+.3) | +--------------------+ | 0.5235987755982989 | +--------------------+ 1 row in set (0.00 sec)
Similarly for expression (-.2+.3) = -.1. You can see in the below screen that both inputs yield the same results.
mysql> SELECT ASIN(-.2+.3); +--------------------+ | ASIN(-.2+.3) | +--------------------+ | 0.1001674211615598 | +--------------------+ 1 row in set (0.00 sec)
mysql> SELECT ASIN(-.1); +---------------------+ | ASIN(-.1) | +---------------------+ | -0.1001674211615598 | +---------------------+ 1 row in set (0.00 sec)