# sin(3)

```NAME
sin, cos, tan, asin, acos, atan,  atan2  -  trigonometric  functions  and
their inverses

SYNOPSIS
#include <math.h>

double sin(double x)
double cos(double x)
double tan(double x)
double asin(double x)
double acos(double x)
double atan(double x)
double atan2(double y, double x)

DESCRIPTION
Sin, cos and tan return trigonometric functions of radian arguments x.

Asin returns the arc sine in the range -pi/2 to pi/2.

Acos returns the arc cosine in the range 0 to pi.

Atan returns the arc tangent in the range -pi/2 to pi/2.

atan2(y, x) :=   atan(y/x)                         if x > 0,
sign(y)*(n - atan(|y/x|))         if x < 0,
0                                 if x = y = 0, or
sign(y)*n/2                       if x = 0 != y.

DIAGNOSTICS
sin(+Inf) = cos(+Inf) = tan(+Inf) = NaN with signal.
sin(NaN) = cos(NaN) = tan(NaN) = that NaN.

asin(NaN) = acos(NaN) = NaN.
asin(x) = acos(x) = NaN with invalid signal if |x| > 1.

atan2([anything], NaN) = NaN;
atan2(NaN , [anything]) = NaN;
atan2(+0, +[anything but NaN]) = +0  ;
atan2(+0, -[anything but NaN]) = +n ;
atan2(+[anything but 0 and NaN], 0) = +n/2;
atan2(+[anything but Inf and NaN], +Inf) = +0 ;
atan2(+[anything but Inf and NaN], -Inf) = +n;
atan2(+Inf, +Inf) = +n/4 ;
atan2(+Inf, -Inf) = +3n/4;
atan2(+Inf, [anything but, 0, NaN, and Inf]) = +n/2;

NOTES
Atan2 defines atan2(0, 0) = 0 for the following reasons:

(1)     Programs that test arguments to avoid computing atan2(0, 0)  must
be  indifferent  to  its  value.   Programs that require it to be
invalid are vulnerable to diverse reactions to that invalidity on
diverse computer systems.

(2)     Atan2 is used mostly to convert from rectangular (x, y) to  polar
(r,  theta) coordinates that must satisfy x = r*cos theta and y =
r*sin theta.  These equations are satisfied when  (x=0,  y=0)  is
mapped  to  (r=0,  theta=0) on a VAX.  In general, conversions to
polar coordinates should be computed thus:

r := hypot(x, y);  ... := sqrt(x*x+y*y)
theta := atan2(y, x).

(3)     The  foregoing  formulas  need  not  be  altered  to  cope  in  a
reasonable way with signed zeros and infinities on a machine that
conforms to IEEE 754; the versions of hypot  and  atan2  provided
for such a machine are designed to handle all cases.  That is why
atan2(+0, -0) = +pi, for instance.  In general the formulas above
are equivalent to these:

r := sqrt(x*x+y*y); if r = 0 then x := copysign(1, x);
if x > 0    then theta := 2*atan(y/(r+x))
else theta := 2*atan((r-x)/y);

except if r is infinite then  atan2  will  yield  an  appropriate
multiple  of  pi/4  that  would  otherwise have to be obtained by
taking limits.

ERROR (due to Roundoff etc.)
Sin,  cos,  and  tan  return  the  nearly  rounded  result  of  the  true
mathematical function, so they approximate within 1 ulp.

math(3), hypot(3), sqrt(3).

AUTHOR
Robert P. Corbett, W. Kahan, Stuart I. McDonald, Peter Tang and, for  the
codes for IEEE 754, Dr. Kwok-Choi Ng.

```