In MariaDB, COT()
is a built-in numeric function that returns the cotangent of its argument.
In trigonometry, in a right triangle, the cotangent of an angle is the length of the adjacent side divided by the length of the opposite side.
Syntax
The syntax goes like this:
COT(X)
Where X
is the number for which to get the cotangent.
Example
Here’s an example:
SELECT COT(45);
Result:
+--------------------+ | COT(45) | +--------------------+ | 0.6173696237835551 | +--------------------+
Fractions
The argument can contain a fractional part:
SELECT COT(4.57);
Result:
+---------------------+ | COT(4.57) | +---------------------+ | 0.14335914325793922 | +---------------------+
Negative Values
The argument can be negative:
SELECT COT(-4.57);
Result:
+----------------------+ | COT(-4.57) | +----------------------+ | -0.14335914325793922 | +----------------------+
Expressions
The argument can include expressions like this:
SELECT COT(0.4 * 1.3);
Result:
+--------------------+ | COT(0.4 * 1.3) | +--------------------+ | 1.7465362641453968 | +--------------------+
Zero Arguments
The argument must be non-zero, as the cotangent of zero doesn’t exist.
SELECT COT(0);
Result:
ERROR 1690 (22003): DOUBLE value is out of range in 'cot(0)'
Non-Numeric Arguments
Here’s an example of what happens when we provide a non-numeric argument:
SELECT COT('Cat');
Result:
ERROR 1690 (22003): DOUBLE value is out of range in 'cot('Cat')'
Null Arguments
COT()
returns null
if the argument is null
:
SELECT COT(null);
Result:
+-----------+ | COT(null) | +-----------+ | NULL | +-----------+
Missing Arguments
Calling COT()
with the wrong number of arguments, or without any arguments results in an error:
SELECT COT();
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'COT'
And:
SELECT COT(10, 2);
Result:
ERROR 1582 (42000): Incorrect parameter count in the call to native function 'COT'