# MySQL ACOS() function

## ACOS() function

MySQL ACOS() returns the arc cosine of a number. The function returns NULL when the value of the number is not between the range -1 to 1. It's a mathematical function that finds the angle whose cosine is the specified number.

This function is useful in -

• It helps in finding angles in right triangles and is used in various fields like physics, engineering, and astronomy.
• While COS() takes an angle and returns its cosine, ACOS() takes a cosine value and returns the angle.
• In geometry, especially in applications dealing with coordinates and vectors, ACOS() is used to calculate angles between vectors or lines.
• ACOS() is used in the calculation of arc lengths in circular segments.
• In computer graphics and animation, ACOS() is used to determine the angles for smooth transitions between orientations of 3D objects.

Syntax:

```ACOS(N)
```

Argument:

Name Description
N A number whose arc cosine value is to be retrieved.

Syntax Diagram:

MySQL Version: 8.0

Example:

Code:

``````SELECT ACOS(1);
```
```

Explanation:

The above MySQL statement will return the cosine value of the number defined as an argument.

Output:

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

Example : ACOS() function using fractional number

Code:

``````SELECT ACOS(1.001);
```
```

Explanation:

The above MySQL statement will return NULL because the value defined in the argument is greater than the range.

Output:

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

Example: ACOS() function using zero(0)

Code:

`````` SELECT ACOS(0);
```
```

Explanation:

The above MySQL statement will return the cosine value of the number defined as an argument.

Output:

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

All Mathematical Functions

Previous: ABS()
Next: ASIN()

﻿