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:
// 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: Function Syntax