acos
Compute the arccosine of the input cosine.
Interface Definition
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 is provided only in the high-precision version.
Fortran interface:
RES = ACOSF(X);
RES = ACOS(X);
Parameters
Parameter |
Type |
Description |
Input/Output |
|---|---|---|---|
x |
|
Floating-point value of a cosine value. |
Input |
Return Value
- The arccosine y of cosine x is returned. x ∈ [-1, +1]
- If the input is ±0, the return value is +π/2.
- If the input is +1, the return value is +0.
- If the input is -1, the return value is +π.
- If the input |x| is greater than 1, the return value is NaN.
- If the input is ±∞, the return value is NaN.
- If the input is NaN, the return value is NaN.
Dependencies
C: "km.h"
Examples
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 | 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
!
Parent topic: Trigonometric Functions