ACOS() returns an angle in radians whose cosine matches the supplied value. Its valid input range is -1 through 1.
Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.
SELECT DEGREES(ACOS(0)) AS angle_degrees;| angle_degrees |
|---|
| 90 |
ACOS(X) returns the arc cosine of X in radians. The input must be between -1 and 1; values outside that range return NULL.
SELECT ACOS(0); -- Output: 1.5707963267948966
SELECT ACOS(1); -- Output: 0
SELECT ACOS(-2); -- Output: NULL
SELECT ROUND(ACOS(0), 2); -- Output: 1.57
SELECT ACOS(X);
The result is the angle whose cosine is X. Use DEGREES() when you want degrees instead of radians.
SELECT DEGREES(ACOS(0)); -- Output: 90
SELECT DEGREES(ACOS(1)); -- Output: 0
SELECT DEGREES(ACOS(-1)); -- Output: 180
ACOS() normally returns radians. Use DEGREES() if the angle should be displayed in degrees.
What happens when the input is outside -1 to 1?
ACOS() returns NULL for an out-of-range input.
Related: ATAN()
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.