cospi
计算输入实数与π相乘的余弦值。
接口定义
C interface:
float cospif(float x);
double cospi(double x);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示输入数据的浮点值。 |
输入 |
返回值
- 返回x乘以π的余弦函数值y=cos(x * π),y ∈ [-1, +1]。
- 输入+0,返回1。
- 输入-0,返回1。
- 输入±∞,返回nan。
- 输入nan,返回nan。
依赖
C: "km.h"
示例
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 * * */
父主题: 三角函数