The COT() function returns the cotangent of a given number, which is expressed in radians.
Syntax
COT(number)
Definition and Usage
- The
COT()function computes the cotangent of a number (in radians). - Cotangent is the reciprocal of the tangent, meaning: cot(x)=1tan(x)\text{cot}(x) = \frac{1}{\text{tan}(x)}
- If the value of
numberis 0, the function will return an error or NULL, as cotangent of 0 is undefined.
Parameter Values
| Parameter | Description |
|---|---|
number |
Required. A numeric value (in radians) to calculate the cotangent for. |
Technical Details
- Works in: From MySQL 4.0
- Result: Returns a numeric value that is the cotangent of the provided number.
Examples
Example 1: Cotangent of a number
SELECT COT(6) AS Result;
Result:
Result: -0.437653722
Explanation: The cotangent of 6 radians is -0.437653722.
Example 2: Cotangent of a negative number
SELECT COT(-2) AS Result;
Result:
Result: -0.642092615
Explanation: The cotangent of -2 radians is -0.642092615.
Example 3: Cotangent of zero
SELECT COT(0) AS Result;
Result:
Result: NULL
Explanation: The cotangent of 0 is undefined, so it returns NULL.
Usage Notes
-
Radians:
- The
COT()function requires the angle to be provided in radians. If the angle is in degrees, you need to convert it using theRADIANS()function.
- The
-
Undefined Value:
- Cotangent is undefined when the tangent is 0, i.e., at multiples of
π(likeπ,2π, etc.). In such cases, the function returnsNULL.
- Cotangent is undefined when the tangent is 0, i.e., at multiples of
Practical Query Example:
Example: Calculate the cotangent of a 45-degree angle
To calculate the cotangent of 45 degrees, first convert it to radians:
SELECT COT(RADIANS(45)) AS CotangentOf45Degrees;
Result:
CotangentOf45Degrees: 1
Explanation: The cotangent of 45 degrees (which is equivalent to π/4 radians) is 1.
The COT() function is useful for trigonometric calculations involving angles, particularly when working with reciprocal trigonometric functions like cotangent.