Rate This Document
Findability
Accuracy
Completeness
Readability

acos

Compute the arc cosine value of a real number.

Interface Definition

C interface:

float acosf(float x);

double acos(double x);

Fortran interface:

RES = ACOSF(X);

RES = ACOS(X);

Parameters

Parameter

Type

Description

Input/Output

x

  • For acosf, x is of single-precision floating-point type.
  • For acos, x is of double-precision floating-point type.

Floating-point value of a radian angle

Input

Return Value

  • Return the arc cosine function value y of the radian angle x. 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"

Fortran: "km.f03"

Examples

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 
    !