# How to get ARC Cosine(ACOS) value in MySQL8?

With MySQL, we can do complex calculations very easily with the help of inbuilt mathematical functions. ACOS(number) helps in getting the angle, in radians, whose sine is provided as input number. Now let’s start with these.

ACOS(number) is a mathematical function. It returns the arc cosine of number, that is, the value whose cosine is number. It returns NULL, if N is not in the range -1.00 to 1.00.

It returns Warning, if any string argument is passed.

## MySQL ACOS() : Syntax

ACOS (number)

### MySQL ACOS() : Parameter

Name, Required /Optional,Type, Description
number , Required, Double , It represents valid number between -1 and 1.

#### MySQL ACOS() : Output

Return, Description
NULL, if the argument is NULL.
Double, It returns arc cosine of number.

#### ACOS() Example 1 :

See the below example. What it returns when 0 is passed.

```mysql> select ACOS(0);
+--------------------+
| ACOS(0) |
+--------------------+
| 1.5707963267948966 |
+--------------------+
1 row in set (0.00 sec)```

See the below value When -1 is passed as an input.

```mysql> select ACOS(-1);
+-------------------+
| ACOS(-1) |
+-------------------+
| 3.141592653589793 |
+-------------------+
1 row in set (0.00 sec)```

See the below value When 1 is passed as an input.

```mysql> select ACOS(1);
+---------+
| ACOS(1) |
+---------+
| 0 |
+---------+
1 row in set (0.00 sec)```

#### ACOS() Example 2 :

Below are some more examples.

```mysql> SELECT ACOS(.13256);
+--------------------+
| ACOS(.13256) |
+--------------------+
| 1.4378449969525082 |
+--------------------+
1 row in set (0.00 sec)

mysql> SELECT ACOS(-.13256);
+-------------------+
| ACOS(-.13256) |
+-------------------+
| 1.703747656637285 |
+-------------------+
1 row in set (0.00 sec)
```

#### ACOS() Example 3 : return Warning if any string argument is passed.

See the below example :

```mysql> SELECT ACOS('TEST123');
+--------------------+
| ACOS('TEST123') |
+--------------------+
| 1.5707963267948966 |
+--------------------+
1 row in set, 1 warning (0.00 sec)

mysql> SHOW WARNINGS;
+---------+------+---------------------------------------------+
| Level | Code | Message |
+---------+------+---------------------------------------------+
| Warning | 1292 | Truncated incorrect DOUBLE value: 'TEST123' |
+---------+------+---------------------------------------------+
1 row in set (0.00 sec)```

You can see the warning message with the help of the ‘SHOW WARNINGS’ command. Please refer above code for the same.

#### ACOS() Example 4 : NULL arguments

If the argument is NULL, it will return NULL. See the below example :

```mysql> select ACOS(NULL);
+------------+
| ACOS(NULL) |
+------------+
| NULL |
+------------+
1 row in set (0.00 sec)```

It will return NULL if the values which are passed are out of range values.

```mysql> SELECT ACOS(2.5698);
+--------------+
| ACOS(2.5698) |
+--------------+
| NULL |
+--------------+
1 row in set (0.00 sec)

mysql> SELECT ACOS(-72.5698);
+----------------+
| ACOS(-72.5698) |
+----------------+
| NULL |
+----------------+
1 row in set (0.00 sec)```

#### ACOS() Example 5 : Using expressions

Here are some more examples to use the expression with the ACOS() function :

```mysql> SELECT ACOS(.5);
+--------------------+
| ACOS(.5) |
+--------------------+
| 1.0471975511965979 |
+--------------------+
1 row in set (0.00 sec)```

We are using an expression in the below example for the above number as (.2+.3) becomes .5. So, We have got the same value.

```mysql> SELECT ACOS(.2+.3);
+--------------------+
| ACOS(.2+.3) |
+--------------------+
| 1.0471975511965979 |
+--------------------+
1 row in set (0.00 sec)```

You can see, We have got 0.06 in the below example.

```mysql> SELECT (.2*.3);
+---------+
| (.2*.3) |
+---------+
| 0.06 |
+---------+
1 row in set (0.00 sec)```

We are using an expression in the below example for the above number as (.2*.3) becomes 0.06. So, We have got the same value.

```mysql> SELECT ACOS(.2*.3);
+--------------------+
| ACOS(.2*.3) |
+--------------------+
| 1.5107602683496182 |
+--------------------+
1 row in set (0.00 sec)

mysql> SELECT ACOS(0.06);
+--------------------+
| ACOS(0.06) |
+--------------------+
| 1.5107602683496182 |
+--------------------+
1 row in set (0.00 sec)```