How ASIN() Works in MariaDB

In MariaDB, ASIN() is a built-in numeric function that returns the arcsine (inverse sine) of its argument.

In other words, it returns the value whose sine is the argument.

Syntax

The syntax goes like this:

ASIN(X)

Where X is a valid expression that resolves to a number between -1 and 1.

Example

Here’s an example:

SELECT ASIN(0.317);

Result:

+--------------------+
| ASIN(0.317)        |
+--------------------+
| 0.3225646710420111 |
+--------------------+

Here are some more examples:

SELECT 
    ASIN(0),
    ASIN(-1),
    ASIN(1);

Result:

+---------+---------------------+--------------------+
| ASIN(0) | ASIN(-1)            | ASIN(1)            |
+---------+---------------------+--------------------+
|       0 | -1.5707963267948966 | 1.5707963267948966 |
+---------+---------------------+--------------------+

Out of Range Argument

The argument must be between -1 and 1. If not, null is returned.

Example:

SELECT ASIN(2);

Result:

+---------+
| ASIN(2) |
+---------+
|    NULL |
+---------+

Non-Numeric Argument

Here’s what happens when we provide a non-numeric argument:

SELECT ASIN('One');

Result:

+-------------+
| ASIN('One') |
+-------------+
|           0 |
+-------------+
1 row in set, 1 warning (0.000 sec)

Let’s check the warning:

SHOW WARNINGS;

Result:

+---------+------+-----------------------------------------+
| Level   | Code | Message                                 |
+---------+------+-----------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'One' |
+---------+------+-----------------------------------------+

Missing Argument

Calling ASIN() without an argument results in an error:

SELECT ASIN();

Result:

ERROR 1582 (42000): Incorrect parameter count in the call to native function 'ASIN'