MySQL ACOS() Function

The ACOS() function calculates the arc cosine (inverse cosine) of a given numeric value.


Syntax

ACOS(number)

Definition and Usage

  • The ACOS() function returns the arc cosine of a number.
  • The result is expressed in radians and is in the range [0, π] (0 to approximately 3.14159).
  • The input value must be between -1 and 1. If the value is outside this range, the function returns NULL.

Parameter Values

Parameter Description
number Required. A numeric value between -1 and 1.

Technical Details

  • Works in: From MySQL 4.0

Examples

Example 1: Arc cosine of a positive number

SELECT ACOS(0.25);

Result:

1.318116071652818

Example 2: Arc cosine of a negative number

SELECT ACOS(-0.8);

Result:

2.498091544796509

Example 3: Arc cosine of 1

SELECT ACOS(1);

Result:

0

Example 4: Arc cosine of -1

SELECT ACOS(-1);

Result:

3.141592653589793

Example 5: Input outside the range

SELECT ACOS(1.5);

Result:

NULL

Usage Notes

  • Use the ACOS() function in trigonometric calculations or geometry problems requiring inverse cosine.
  • To convert radians to degrees, multiply the result by 180π\frac{180}{\pi}:
    SELECT ACOS(0.25) * (180 / PI());
    

Result in degrees:

75.52248781407008

Was this article helpful?