MySQL ACOS Function

The MySQL ACOS function is one of the Numeric Functions which calculates the trigonometry Arc cosine of the specified expression. The basic syntax of the MySQL ACOS Function is as shown below:

SELECT ACOS (Numeric_Expression)
FROM Source
  • If the Numeric_Expression is between -1 and +1, the ACOS Function returns the arc cosine of the value.
  • If the Numeric_Expression is not between -1 and +1, then it returns NULL.
  • And, If you pass the NULL value, then the function returns NULL.

To demonstrate this Numeric method, we are going to use the below-shown data.

Table 1

MySQL ACOS Function Example

The ACOS function returns the trigonometric Arc cosine of any numeric value. The following Arc cosine example query shows multiple ways to use this method.

-- Negative
SELECT ACOS(-0.65) AS `ArcCosineValue`;

-- Positive
SELECT ACOS(0.59) AS `ArcCosineValue`;

-- Numeric Expression
SELECT ACOS(1.75 + 2.25 - 3.65) AS `ArcCosineValue`;

-- string number
SELECT ACOS('0.29') AS `ArcCosineValue`;

-- String text
SELECT ACOS('MySQL') AS `ArcCosineValue`;

In the below statement, We used this to find the Arc Cosine of different values.

ACOS Function Example 1

The Numeric method also allows you to find the arc cosine of the data in a table column. In this MySQL example, we are going to find the arc cosine for all the records present in the ServiceGrade column.

SELECT Product, Color,
		StandardCost, Sales, TaxAmt, 
        ServiceGrade,
        ACOS(ServiceGrade) AS `Arc Cosine Value`
FROM `numeric functions`;
MySQL ACOS Example 2