TRIG(3M) — MATHEMATICAL LIBRARY
NAME
sin, cos, tan, asin, acos, atan, atan2 − trigonometric functions
SYNOPSIS
#include <math.h>
double sin(x)
double x;
double cos(x)
double x;
void sincos(x, s, c)
double x, ∗s, ∗c;
double tan(x)
double x;
double asin(x)
double x;
double acos(x)
double x;
double atan(x)
double x;
double atan2(y, x)
double y, x;
double sinpi(x)
double x;
double cospi(x)
double x;
void sincospi(x, s, c)
double x, ∗s, ∗c;
double tanpi(x)
double x;
double asinpi(x)
double x;
double acospi(x)
double x;
double atanpi(x)
double x;
double atan2pi(y, x)
double y, x;
DESCRIPTION
sin(), cos(), sincos(), and tan() return trigonometric functions of radian arguments. The values of trigonometric functions of arguments exceeding π/4 in magnitude are affected by the precision of the approximation to π/2 used to reduce those arguments to the range −π/4 to π/4. Argument reduction may occur in hardware or software; if in software, the variable fp_pi defined in <math.h> allows changing that precision at run time. Trigonometric argument reduction is discussed in the Floating-Point Programmer’s Guide. Note: sincos(x,s,c) allows simultaneous computation of ∗s = sin(x) and ∗c = cos(x).
asin() returns the arc sin in the range −π/2 to π/2.
acos() returns the arc cosine in the range 0 to π.
atan() returns the arc tangent of x in the range −π/2 to π/2.
atan2(y,x) and hypot(x,y) (see hypot(3M)) convert rectangular coordinates (x,y) to polar (r,θ); atan2() computes θ, the argument or phase, by computing an arc tangent of y/x in the range −π to π. atan2(0.0,0.0) is ±0.0 or ±π, in conformance with 4.3BSD.
sinpi(), cospi(), and tanpi() avoid range-reduction issues because their definition sinpi(x)==sin(π∗x) permits range reduction that is fast and exact for all x. The corresponding inverse functions compute asinpi(x)==asin(x)/π. Similarly atan2pi(y,x)==atan2(y,x)/π.
DIAGNOSTICS
These functions handle exceptional arguments in the spirit of ANSI/IEEE Std 754-1985. sin(±∞), cos(±∞), tan(±∞), or asin(x) or acos(x) with |x|>1, return NaN; sinpi(x) et. al. are similar. In addition, asin(), acos(), and atan2() may also set errno and call matherr(3M).
SEE ALSO
Solbourne Computer, Inc. — 13 Dec 1990