MySQL ACOS Function

How to find Arc Cosine Value in MySQL?. 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 ACOS in MySQL 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 NULL value, then the function returns NULL.

To demonstrate this MySQL ACOS Numeric function, we are going to use the below shown data

MySQL ACOS Function 1

MySQL ACOS Function Example 1

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

-- MySQL ACOS Function Example

-- Arc Cosine of Negative Value
SELECT ACOS(-0.65) AS `Arc Cosine Value`;

-- Arc Cosine of Positive Value
SELECT ACOS(0.59) AS `Arc Cosine Value`;

-- Arc Cosine of Numeric Expression
SELECT ACOS(1.75 + 2.25 - 3.65) AS `Arc Cosine Value`;

-- Arc Cosine of string value
SELECT ACOS('0.29') AS `Arc Cosine Value`;

-- Arc Cosine of String
SELECT ACOS('MySQL') AS `Arc Cosine Value`;

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

MySQL ACOS Example 1

MySQL ACOS Example 2

The ACOS Numeric Function 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.

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

MySQL ACOS Example 2