arc cosine function

You're viewing an older version of this page (#3226). 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 )

#include <complex.h> complex acos(complex x) double complex cacos(double complex x) float complex cacosf(float complex x) long double complex cacosl(long double complex x)

DESCRIPTION

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

The complex inverse cosine is defined by

acos(x) = -i \log \left( x+ i \sqrt{1-x^2} \right )
(1)

Example 1

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

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

SPECIAL VALUES

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

SEE ALSO

sin (3) , cos (3) , tan (3) , asin (3) , atan (3) , atan2 (3) , sinh (3) , cosh (3) , tanh (3)

STANDARDS

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

COMPATIBILITY

<table class="compat"> <tr><th></th><th>DOS</th><th>UNIX</th><th>Windows</th><th>ANSI C</th><th>C++ only</th></tr> <tr><td>acosl</td><td>&bull;</td><td></td><td>&bull;</td><td></td><td></td></tr> <tr><td>Real acos</td><td>&bull;</td><td>&bull;</td><td>&bull;</td><td>&bull;</td><td></td></tr> <tr><td>Complex acos</td><td>&bull;</td><td></td><td>&bull;</td><td></td><td>&bull;</td></tr> <tr><td>Complex cacos</td><td></td><td>&bull;</td><td></td><td></td><td>&bull;</td></tr> </table>