COTPI Function (Gnumeric)
Use COTPI in Gnumeric to calculate cotangent of a multiple of pi. Includes half-turn examples, singularities and degree conversion.
Verification status: Official documentation referenced; example outcomes independently reasoned or arithmetically checked where stated. Not executed in Gnumeric. How formula examples are checked
Quick answer
=COTPI(0.25) has the independently calculated mathematical value 1: cot(π/4) = 1. =COTPI(0.5) is mathematically 0. At =COTPI(0) the real cotangent is undefined, and the precise Gnumeric error/display behaviour has not been verified.
Exact Gnumeric syntax and input units
COTPI(x)
The official Gnumeric Mathematics manual defines COTPI(x) as cot(π × x). Its one required numeric argument x represents half turns. There are no documented optional arguments or defaults. x=0.25 corresponds to 45°, and x=0.5 corresponds to 90°. Cotangent is cos(angle)/sin(angle) wherever the denominator is not zero. This function was added in Gnumeric 1.12.22, according to the GNOME release notes. No Gnumeric version was executed for this guide.
Enter a numeric multiplier in A2 and use =COTPI(A2). When source values are degrees, use =COTPI(A2/180); for source radians, use =COT(A2). Decimal examples below use an English-locale period, and any multi-argument wrapper must use the recipient locale’s separator. COTPI itself takes one argument, so it needs no separator.
Reproducible values and undefined points
Enter A2:A8 as below and use =COTPI(A2) in B2, filling down. The last two cases are intentionally mathematically undefined and should be reviewed natively before treating a displayed error as a verified application result.
| Row | A: half turns | Formula | Expected mathematical value |
|---|---|---|---|
| 2 | 0.125 | =COTPI(A2) |
√2 + 1 ≈ 2.4142135624 |
| 3 | 0.25 | =COTPI(A3) |
1 |
| 4 | 0.5 | =COTPI(A4) |
0 |
| 5 | −0.25 | =COTPI(A5) |
−1 |
| 6 | 0.75 | =COTPI(A6) |
−1 |
| 7 | 0 | =COTPI(A7) |
Undefined mathematically |
| 8 | 1 | =COTPI(A8) |
Undefined mathematically |
Cotangent is undefined whenever x is an integer, since sin(πx)=0. Do not infer Gnumeric’s exact #DIV/0!, #NUM! or another return from mathematics alone. Its documented catalogue calls COTPI complete with no project testsuite. This classification is not evidence that any case above was natively tested.
Practical application: horizontal run from a rise
A survey sketch gives a straight ramp’s rise of 4 metres, while its incline angle is 45°. If A2 holds the angle measured in half turns (0.25) and B2 holds the rise (4), calculate horizontal run by:
=B2*COTPI(A2)
The independently calculated expected run is 4 metres. At 22.5° (A2=0.125), the expected run is 4 × (√2+1) ≈ 9.6568542495 metres. This application assumes a nonzero rise and a nonhorizontal, well-defined slope; it does not substitute for site measurements.
Advanced case: avoiding division by nearly zero
A mathematically motivated but not Gnumeric-tested worksheet guard for an input in A2 is:
=IF(ABS(SINPI(A2))<0.0000000001,"Undefined/near horizontal",COTPI(A2))
Here SINPI checks the sine denominator of cotangent. The threshold is an example application policy, not a Gnumeric-recommended tolerance. A very small but nonzero angle can have a finite, extremely large cotangent and still be labeled “near horizontal” by this rule. Localize the separator inside IF when required.
=1/TANPI(A2) is a familiar mathematical rewrite where tangent is nonzero and defined, but it is not safe everywhere: at x=0.5, COTPI has a finite mathematical value 0 while tangent is undefined. The alternate rewrite =COS(PI()*A2)/SIN(PI()*A2) similarly needs a zero-denominator check and can have rounding differences.
Troubleshooting and limits
- Input in degrees rather than half turns:
COTPI(45)is not cotangent of 45°. Use=COTPI(45/180)or a radians-based COT formula. - Integer x: the mathematical cotangent is undefined; native execution is required to document the actual error return.
- Tiny angles: outputs can grow in magnitude and become sensitive to input precision, which should be disclosed to readers applying measurement data.
- Text and blank cells: numeric input is documented, but coercion and exact Gnumeric error behaviour remain unverified.
- Portability: the vendor’s “complete” label is not an Excel support certification. For a recipient lacking COTPI, a fallback is
=COS(PI()*A2)/SIN(PI()*A2), with singularity and precision caveats; confirm support in that application’s version.
Related Gnumeric functions
How this guide was checked
The official Gnumeric reference establishes the function’s purpose and argument structure. The arguments and worked examples were editorially reviewed and the stated expected results were independently calculated.
Review date: 2026-10-12. No native application run: the worked outputs are documentation-based or independently calculated expectations, not measurements from installed Gnumeric. Ordinary numeric cases and the stated text-construction examples are checked; blank/text coercion, machine extremes and workbook round trips are not certified. The formula editor in your installed version is the authority for localized separators.