Function Reference

COS

Returns the cosine of an angle given in radians.

MySQL 8.1
COS(angle)

Parameters

angleDOUBLE
Angle in radians

Return value

A floating-point number from -1 to 1

Examples

Cosine of a straight angle

MySQL 8.1
SELECT COS(PI());
COS(PI())
-1

Cosine of 60° rounded

MySQL 8.1
SELECT COS(RADIANS(60)) AS raw,
	ROUND(COS(RADIANS(60)), 2) AS rounded;
rawrounded
0.50000000000000010.5

Details

To convert degrees to radians, use the RADIANS function: COS(RADIANS(60)).

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

See also

Where to learn