www.delorie.com/djgpp/doc/libc/libc_113.html   search  
libc.a reference

[ < ] [ > ]   [ << ] [ Up ] [ >> ]         [Top] [Contents] [Index] [ ? ]

cos

Syntax

 
#include <math.h>

double cos(double x);

Description

This function computes the cosine of x (which should be given in radians).

Return Value

The cosine of x. If the absolute value of x is finite but greater than or equal to 2^63, the value is 1 (since for arguments that large each bit of the mantissa is more than Pi). If the value of x is infinite or NaN, the return value is NaN and errno is set to EDOM.

Portability

ANSI/ISO C C89; C99
POSIX 1003.2-1992; 1003.1-2001

Accuracy

In general, this function's relative accuracy is about 1.7*10^(-16), which is close to the machine precision for a double. However, for arguments very close to Pi/2 and its odd multiples, the relative accuracy can be many times worse, due to loss of precision in the internal FPU computations. Since cos(Pi/2) is zero, the absolute accuracy is still very good; but if your program needs to preserve high relative accuracy for such arguments, link with `-lm' and use the version of cos from `libm.a' which does elaborate argument reduction, but is about three times slower.

  webmaster   donations   bookstore     delorie software   privacy  
  Copyright 2004   by DJ Delorie     Updated Apr 2004