PostgreSQL acos() Function

The PostgreSQL acos() function returns the arc cosine of a specified number in radians.

acos() Syntax

This is the syntax of the PostgreSQL acos() function:

acos(number)

Parameters

number

Required. The number used to calculate the arc cosine. It should be between -1 and 1, inclusive.

Return value

The PostgreSQL acos() function returns the arc cosine of a specified number in radians.

If the argument number is not between -1 and 1, the acos() function will throw an error.

If the parameter number is NULL, the acos() function will return NULL.

acos() Examples

Here are a few examples of the acos() function:

SELECT
    acos(-1) AS "acos(-1)",
    acos(-0.5) AS "acos(-0.5)",
    acos(-0.2) AS "acos(-0.2)",
    acos(0) AS "acos(0)",
    acos(0.2) AS "acos(0.2)",
    acos(0.5) AS "acos(0.5)",
    acos(1) AS "acos(1)";
-[ RECORD 1 ]------------------
acos(-1)   | 3.141592653589793
acos(-0.5) | 2.0943951023931957
acos(-0.2) | 1.7721542475852274
acos(0)    | 1.5707963267948966
acos(0.2)  | 1.369438406004566
acos(0.5)  | 1.0471975511965979
acos(1)    | 0