Function Reference

COS

Returns the cosine of an angle given in radians.

PostgreSQL 17.9
COS(angle)
angle
Angle in radians
double precision

Return value

A floating-point number (double precision) from -1 to 1

Examples

Cosine of a straight angle

PostgreSQL 17.9
SELECT COS(PI());
cos
-1

Angle in radians and in degrees

PostgreSQL 17.9
SELECT COS(RADIANS(60)) AS from_radians,
	COSD(60) AS from_degrees;
from_radiansfrom_degrees
0.50000000000000010.5

Details

For an angle in degrees, use COSD.

COS(PI() / 2) gives about 6e-17, not exactly 0.

See also

Where to learn