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
SELECT COS(X);
Use ROUND() to limit displayed decimals and PI() for π.
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
Author & Instructor at plus2net
I write and maintain practical tutorials on Python, PHP, SQL, JavaScript, HTML, jQuery, and web development at plus2net. The tutorials focus on clear explanations, working examples, and code that readers can test and adapt while learning.