Chapter Contents

Previous

Next
acos

acos



Compute the Trigonometric Arc Cosine

Portability: ISO/ANSI C conforming, UNIX compatible


SYNOPSIS
DESCRIPTION
RETURN VALUE
DIAGNOSTICS
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <math.h>

double acos(double x);


DESCRIPTION

acos computes the trigonometric arc cosine of the argument x . The arc cosine function is the inverse of the trigonometric cosine function and is expressed by the following relation:

[IMAGE]

x is in the closed interval [-1.0,1.0] .


RETURN VALUE

acos returns the principal value of the arc cosine of the argument x , provided that this value is defined and computable. The return value is a double precision floating-point number in the closed interval [0,[pi]] radians.


DIAGNOSTICS

An error message is written to the standard error file ( stderr ) by the run-time library if x is not in the domain [-1.0,1.0] . In this case, the function returns 0.0.

If an error occurs in acos , the _matherr routine is called. You can supply your own version of _matherr to suppress the diagnostic message or modify the value returned.


EXAMPLE

This example computes the value of pi:

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

main()
{
   double pi;

   /* pi is equal to the arc cosine of .5 times 3. */
   pi = 3 * acos(.5);

   printf("3 * acos(%f) = %f\n", .5, pi);
}


RELATED FUNCTIONS

asin , atan , _matherr


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.