cospi
Compute the cosine of the input real number multiplied by π.
Interface Definition
C interface:
float cospif(float x);
double cospi(double x);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of the input data. |
Input |
Return Value
- The cosine y of the input x multiplied by π is returned, that is, y = cos(x * π). y ∈ [-1, +1]
- If the input is +0, the return value is 1.
- If the input is -0, the return value is 1.
- If the input is ±∞, the return value is NaN.
- If the input is NaN, the return value 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 27 28 29 30 31 32 | // print result printf("cospi(0.0) = %.15f\n", cospi(0.0)); printf("cospi(-0.0) = %.15f\n", cospi(-0.0)); printf("cospi(0.25) = %.15f\n", cospi(0.25)); printf("cospi(-0.25) = %.15f\n", cospi(-0.25)); printf("cospi(0.5) = %.15f\n", cospi(0.5)); printf("cospi(-0.5) = %.15f\n", cospi(-0.5)); printf("cospi(1.0) = %.15f\n", cospi(1.0)); printf("cospi(-1.0) = %.15f\n", cospi(-1.0)); printf("cospi(2.0) = %.15f\n", cospi(2.0)); printf("cospi(-2.0) = %.15f\n", cospi(-2.0)); printf("cospi(INFINITY) = %.15f\n", cospi(INFINITY)); printf("cospi(-INFINITY) = %.15f\n", cospi(-INFINITY)); printf("cospi(NAN) = %.15f\n", cospi(NAN)); printf("cospi(-NAN) = %.15f\n", cospi(-NAN)); /* * cospi(0.0) = 1.000000000000000 * cospi(-0.0) = 1.000000000000000 * cospi(0.25) = 0.707106781186548 * cospi(-0.25) = 0.707106781186548 * cospi(0.5) = 0.000000000000000 * cospi(-0.5) = 0.000000000000000 * cospi(1.0) = -1.000000000000000 * cospi(-1.0) = -1.000000000000000 * cospi(2.0) = 1.000000000000000 * cospi(-2.0) = 1.000000000000000 * cospi(INFINITY) = nan * cospi(-INFINITY) = nan * cospi(NAN) = nan * cospi(-NAN) = -nan * * */ |
Parent topic: Trigonometric Functions