Borland C++ reference

cos, cosl

raw OCR

Calculates the cosine of a value.

Defined in header <math.h>

Syntax

Real versions:                             Complex version:
#include <math.h>                         #include <complex.h>
double cos(double x);                      complex cos(complex  x);
long double cosl(long double x);

Portability

DOSUNIXWindowsANSI CC++ only
cosI ■■
Real cos ■■■■
Complex cos ■■■

Remarks

COS computes the cosine of the input value. The angle is specified in radians.

cos I is the long double version; it takes a long double argument and returns a long double result.

The complex cosine is defined by

cosCz) = (exp(f * z) + exp(-2 * z))/2

Return value

cos of a real argument returns a value in the range -1 to 1.

Error handling for these functions can be modified through matherr (or _matherrl).

See also

Example

#include <stdio.h>
#include <math.h>
int main(void)
double result, x = 0.5;
result = cos(x);
printfC'The cosine of %lf is %lf\n", x,  result);
return 0;

Differences from modern implementations

Nothing recorded yet.

Modern references

These are search links, not yet checked by hand.

Extraction notes

  • heading `COS, cosi` read as `cos, cosl`