In MySQL, the COT()
function returns the cotangent of a given value.
You provide the value as an argument when calling the function.
Syntax
The syntax goes like this:
COT(X)
Where X
is the value for which you’d like the cotangent returned.
Example 1 – Basic Usage
Here’s a basic example to demonstrate what COT()
returns for a given number.
SELECT COT(1);
Result:
+--------------------+ | COT(1) | +--------------------+ | 0.6420926159343308 | +--------------------+
And here’s another example using a different number.
SELECT COT(5);
Result:
+---------------------+ | COT(5) | +---------------------+ | -0.2958129155327456 | +---------------------+
Example 2 – Passing in Negative Numbers
Here are the two previous examples, except this time using a negative value instead of positive.
SELECT COT(-1);
Result:
+---------------------+ | COT(-1) | +---------------------+ | -0.6420926159343308 | +---------------------+
And here’s another example using a different number.
SELECT COT(-5);
Result:
+--------------------+ | COT(-5) | +--------------------+ | 0.2958129155327456 | +--------------------+
Example 3 – Passing in Zero
Passing in zero will result in an “out of range” error.
SELECT COT(0);
Result:
ERROR 1690 (22003): DOUBLE value is out of range in 'cot(0)'