In MySQL, the ASIN()
function returns the arc sine of a number.
You provide the number as an argument when calling the function.
Syntax
The syntax goes like this:
ASIN(X)
Where X
is the value for which you’d like the arc sine returned. The argument must be a value in the range -1
to 1
. If it’s outside of that range, NULL
is returned.
Example 1 – Basic Usage
Here’s a basic example.
SELECT ASIN(0.1);
Result:
+--------------------+ | ASIN(0.1) | +--------------------+ | 0.1001674211615598 | +--------------------+
Here’s what happens when you provide a value of 1
.
SELECT ASIN(1);
Result:
+--------------------+ | ASIN(1) | +--------------------+ | 1.5707963267948966 | +--------------------+
And here’s what happens when you provide a value of -1
.
SELECT ASIN(-1);
Result:
+---------------------+ | ASIN(-1) | +---------------------+ | -1.5707963267948966 | +---------------------+
Example 2 – Out-Of-Range Values
As mentioned, providing a value outside the range -1
to 1
returns a NULL value.
SELECT ASIN(2);
Result:
+---------+ | ASIN(2) | +---------+ | NULL | +---------+
Example 3 – Expressions
You can also pass in expressions like this:
SELECT ASIN(0.1 + 0.3);
Result:
+---------------------+ | ASIN(0.1 + 0.3) | +---------------------+ | 0.41151684606748806 | +---------------------+
Example 4 – Zero
Zero is within the accepted range.
SELECT ASIN(0);
Result:
+---------+ | ASIN(0) | +---------+ | 0 | +---------+
Example 5 – NULL
Passing in NULL
returns NULL
.
SELECT ASIN(NULL);
Result:
+------------+ | ASIN(NULL) | +------------+ | NULL | +------------+
Return the Arc Cosine
You can also return the arc cosine of a value using the ACOS()
function.