MySQL COS() Function: Find the cosine of an angle

COS() calculates the cosine of an angle given in radians. Convert degrees with RADIANS() before passing them to COS().

COS(): Quick SQL Example

Run this SELECT query directly in MySQL or phpMyAdmin. It uses fixed inputs so you can verify the result without creating a table.

SELECT ROUND(COS(RADIANS(60)), 2) AS cosine_value;
cosine_value
0.50
On this page — Show page sectionsHide page sections

More SQL Examples and Explanations

COS(X) returns the cosine of X, where X is in radians.

SELECT COS(PI()); -- Output: -1
SELECT ROUND(COS(PI() / 2), 2); -- Output: 0.00
SELECT ROUND(COS(PI() / 3), 2); -- Output: 0.50

Syntax

SELECT COS(X);

Use ROUND() to limit displayed decimals and PI() for π.

COS() with RADIANS()

RADIANS() converts degrees to radians.

SELECT COS(RADIANS(0)); -- Output: 1
SELECT ROUND(COS(RADIANS(90)), 2); -- Output: 0.00
SELECT COS(RADIANS(180)); -- Output: -1

How to Interpret the Result

Trigonometric functions accept radians. COS(60) is not the cosine of 60 degrees.

Common Question

Why is COS(PI()/2) not always exactly zero?
Floating-point calculations can produce a very small residual; use ROUND() for display.

Further Reading

All Math Functions SIN() TAN()

↑ Back to top




Subscribe to our YouTube Channel here



plus2net.com




SQL Video Tutorials










✖
We use cookies to improve your browsing experience. . Learn more
HTML MySQL PHP JavaScript ASP Photoshop Articles Contact us
© 2000-2026 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer