acos
计算输入余弦值的反余弦值。
接口定义
C interface:
float acosf(float x);
double acos(double x);
long double acosl(long double x);
long double acosl_18(long double x);
acosl_18仅在高精度版本提供。
Fortran interface:
RES = ACOSF(X);
RES = ACOS(X);
参数
参数名 |
类型 |
描述 |
输入/输出 |
---|---|---|---|
x |
|
表示余弦值的浮点值。 |
输入 |
返回值
- 返回余弦值x的反余弦函数值y,x ∈ [-1, +1]。
- 输入±0,返回+π/2。
- 输入+1,返回+0。
- 输入-1,返回+π。
- 输入|x| > 1,返回nan。
- 输入±∞,返回nan。
- 输入nan,返回nan。
依赖
C: "km.h"
示例
C interface:
double pi = acos(-1); // typical usage double a = pi/6, b = pi/9, c = -3*pi/4, d = 0.0; // special handling double e = INFINITY, f = -INFINITY, g = NAN; // print result printf("acos(pi/6) = %.15f\n", acos(a)); printf("acos(pi/9) = %.15f\n", acos(b)); printf("acos(-3*pi/4) = %.15f\n", acos(c)); printf("acos(0.0) = %.15f\n", acos(d)); printf("acos(INFINITY) = %.15f\n", acos(e)); printf("acos(-INFINITY) = %.15f\n", acos(f)); printf("acos(NAN) = %.15f\n", acos(g)); /* * acos(pi/6) = 1.019726743695450 * acos(pi/9) = 1.214222261943226 * acos(-3*pi/4) = nan * acos(0.0) = 1.570796326794897 * acos(INFINITY) = nan * acos(-INFINITY) = nan * acos(NAN) = nan * * */
Fortran interface:
REAL(8) :: X = 0.0 PRINT*, ACOS(X) ! ! OUTPUT ! 1.570796326794897 !
父主题: 三角函数