@c ---------------------------------------------------------------------- @node cos, math @findex cos @subheading Syntax @example #include double cos(double x); @end example @subheading Description This function computes the cosine of @var{x} (which should be given in radians). @subheading Return Value The cosine of @var{x}. If the absolute value of @var{x} is finite but greater than or equal to @math{2^63}, the value is 1 (since for arguments that large each bit of the mantissa is more than @code{Pi}). If the value of @var{x} is infinite or @code{NaN}, the return value is @code{NaN} and @code{errno} is set to @code{EDOM}. @subheading Portability @portability ansi, posix @subheading Accuracy In general, this function's relative accuracy is about @math{1.7*10^(-16)}, which is close to the machine precision for a @code{double}. However, for arguments very close to @code{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 @math{cos(Pi/2)} is zero, the absolute accuracy is still very good; but if your program needs to preserve high @emph{relative} accuracy for such arguments, link with @samp{-lm} and use the version of @code{cos} from @file{libm.a} which does elaborate argument reduction, but is about three times slower.