arc cosine function

You're viewing an older version of this page (#3334). View the current version.

View versions (4)

NAME

acos

INTERFACE

#include <math.h> double acos (double x) long acosl (long double x) float acosf (float x)

DESCRIPTION

The acos function computes the principal value of the arc cosine of x in the range [0, \pi]. acosl is a long double verion; it takes a long double argument and returns a long double result.

The arc cosine is the inverse cosine, usually donated as cos^{-1}(x). It is a multi valued functions of the following form:

ArcCos-2.gif

Example 1

#include <stdio.h>
#include <math.h>

int main(void)
{
  double result, x=0.5;
  result = acos(x);
  printf("The arc cosine of %lf is %lf\n", x, result);
  return 0;
}

output

The arc cosine of 0.500000 is 1.047198

SPECIAL VALUES

acos ( 1 ) returns +0.
acos ( x ) returns a NAN and raises the invalid floating-point exception for |x| > 1.

SEE ALSO

sin, cos , tan, asin, atan , atan2, sinh , cosh , tanh

STANDARDS

The acos function conforms to ISO/IEC 9899:1999(E).