cot
Compute the cotangent of the input radian.
Interface Definition
C interface:
float cotf(float x);
double cot(double x);
long double cotl(long double x);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of a radian angle. |
Input |
Return Value
- Normal range: The cotangent y of radian angle x is returned, that is, y = cos(x)/sin(x). y ∈ [-∞, +∞]
- If the input x = π * k (k is an integer), the output is ±inf.
- If the input x = π * k + π/2 (k is an integer), the output is ±0.
- If the input |x| = inf or NaN, the output is NaN.
Dependency
C: "km.h"
Example
C interface:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | // typical usage float x1 = -1.0, x2 = 1.0, x3 = 0.5, x4 = -0.5; // special handling float a = 0.0, b = INFINITY, c = -INFINITY, d = NAN; // print result printf("cot(1.0) = %.15f\n", cot(x1)); printf("cot(-1.0) = %.15f\n", cot(x2)); printf("cot(0.5) = %.15f\n", cot(x3)); printf("cot(-0.5) = %.15f\n", cot(x4)); printf("cot(0.0) = %.15f\n", cot(a)); printf("cot(-0.0) = %.15f\n", cot(-a)); printf("cot(INFINITY) = %.15f\n", cot(b)); printf("cot(-INFINITY) = %.15f\n", cot(c)); printf("cot(NAN) = %.15f\n", cot(d)); /* * cot(1.0) = -0.642092615934331 * cot(-1.0) = 0.642092615934331 * cot(0.5) = 1.830487721712452 * cot(-0.5) = -1.830487721712452 * cot(0.0) = inf * cot(-0.0) = -inf * cot(INFINITY) = nan * cot(-INFINITY) = nan * cot(NAN) = nan * * */ |
Parent topic: Trigonometric Functions