cot
Use the cot() function to calculate the cotangent of a numeric value specified in radians. The cotangent is the reciprocal of the tangent function.
Syntax
cot(<numeric_expression>)Parameters
numeric_expression
integer, float
Yes
The angle in radians for which to calculate the cotangent. The value must not be zero or a multiple of π.
Returns
Type: float
Description: The cot() function returns the cotangent of the input angle, which is equivalent to cos(x) / sin(x) or 1 / tan(x). If the input is null, the function returns null.
Usage notes
Input type: XQL doesn't support NaN or infinite values as input and these value types also can not be returned.
Valid Input Range: The
cot()function accepts any real number except values wheresin(x) = 0(i.e., multiples of π), where the cotangent is undefined.Undefined Values: At
x = 0and multiples of π, the function returnsinfinity,NaN, ornullsince the cotangent is undefined at these points.Null Handling: If the input expression is
null, the function returnsnull.Relationship:
cot(x) = 1 / tan(x) = cos(x) / sin(x).Common Use Cases: This function is typically used within the
alterstage for trigonometric calculations, geometric analysis, and engineering computations.
Examples
Example 1: Calculate cotangent of literal values
Goal: Calculate the cotangent for specific radian values to verify known mathematical results.
XQL code:
Explanation: You use cot() on three different radian values. cot(π/4) returns 1.0 (since tan(π/4) = 1), cot(π/2) returns approximately 0.0 (since tan(π/2) approaches infinity), and cot(1) returns approximately 0.6421.
Output:
1.0
0.0
0.64209
Example 2: Calculate cotangent from a field value
Goal: Calculate the cotangent of values stored in a dataset field, filtering out values near zero.
XQL code:
Explanation: This query filters out zero values (where cotangent is undefined), then computes the cotangent for each remaining value in the numeric_value field.
Output:
101
0.5
1.83049
102
1.0
0.64209
103
2.0
-0.45766
Example 3: Verify cotangent as reciprocal of tangent
Goal: Demonstrate that cot(x) equals 1 / tan(x) by computing both and comparing.
XQL code:
Explanation: This query computes both cot(numeric_value) and 1 / tan(numeric_value) to verify they produce the same result, confirming the mathematical identity cot(x) = 1 / tan(x).
Output:
101
0.5
1.83049
1.83049
102
1.0
0.64209
0.64209
103
2.0
-0.45766
-0.45766
Related articles
Datasets:
xdr_data
Last updated
Was this helpful?
