COT() returns the cotangent of an angle measured in radians, which is the reciprocal of TAN() where defined.
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(COT(RADIANS(45)), 2) AS cotangent_value;| cotangent_value |
|---|
| 1.00 |
COT(X) returns the cotangent of X in radians. Cotangent is undefined where the sine is zero; for example, COT(0) produces an out-of-range error in current MySQL rather than a normal numeric result.
SELECT ROUND(COT(PI() / 2), 2); -- Output: 0.00
SELECT ROUND(COT(PI() / 3), 2); -- Output: 0.58
SELECT COT(1); -- Finite cotangent value
SELECT COT(X);
Use PI() for π and ROUND() when you need fewer decimal places.
SELECT COT(RADIANS(45)); -- Output: 1
SELECT ROUND(COT(RADIANS(90)), 2); -- Output: 0.00
-- Avoid 0°, 180° and other points where cotangent is undefined
COT(0) produces an out-of-range error in MySQL. Do not use COT() where the sine is zero.
Can I use degrees directly with COT()?
No. Use RADIANS() to convert degree values before calculation.
Related: ASIN()
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.