COHERENT manpages

This page displays the COHERENT manpage for acos() [Calculate inverse cosine].

List of available manpages
Index


acos() -- Mathematics Function (libm)

Calculate inverse cosine
#include <math.h>
double acos(arg) double arg;

acos() calculates the inverse cosine.  arg  should be in the range of -1.0,
1.0.   It returns the  result, which  is in  the range of  from zero  to pi
radians.

Example

This  example demonstrates  the mathematics  functions acos(),  cabs(), and
tan().

#include <errno.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#define display(x) dodisplay((double)(x), #x)

dodisplay(value, name)
double value; char *name;

{
    if (errno)
        perror(name);
    else
        printf("%10g %s\n", value, name);
    errno = 0;
}

main()
{
    extern char *gets();
    double x;
    char string[64];

    for(;;) {
        printf("Enter number: ");
        if(gets(string) == NULL)
            break;

        x = atof(string);
        display(x);
        display(acos(cos(x)));
        display(cabs(sin(x),cos(x)));
    }
}

See Also

cos(),
errno,
errno.h,
libm,
perror()
ANSI Standard, §7.5.2.1
POSIX Standard, §8.1