PostgreSQL cos() Function

The PostgreSQL cos() function returns the cosine of the specified radian.

cos() Syntax

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

cos(number)

Parameters

number

Required. The number used to calculate the cosine, in radians.

Return value

The PostgreSQL cos() function returns the cosine of the specified radian.

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

cos() Examples

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

SELECT
    cos(2.5) AS "cos(2.5)",
    cos(0.2) AS "cos(0.2)",
    cos(-0.5) AS "cos(-0.5)",
    cos(-0.2) AS "cos(-0.2)",
    cos(0) AS "cos(0)",
    cos(pi()) AS "cos(pi())";
-[ RECORD 1 ]------------------
cos(2.5)  | -0.8011436155469337
cos(0.2)  | 0.9800665778412416
cos(-0.5) | 0.8775825618903728
cos(-0.2) | 0.9800665778412416
cos(0)    | 1
cos(pi()) | -1

Here, we use the pi() function to obtain an approximation of pi.