TRIG(3M)TRIG(3M)


NAME
     acos, asin, atan, atan2, cos, sin, tan, acosf, asinf, atanf, atan2f,
     cosf, sinf, tanf, acosl, asinl, atanl, atan2l, cosl, sinl, tanl,
     cacos, casin, catan, ccos, csin, ctan, cacosf, casinf, catanf, ccosf,
     csinf, csinf, ctanf, cacosl, casinl, catanl, ccosl, csinl, ctanl -
     trigonometric functions and their inverses

SYNOPSIS
     #include <math.h>

     double acos(double x);
     float acosf(float x);
     long double acosl(long double x);

     double asin(double x);
     float asinf(float x);
     long double asinl(long double x);

     double atan(double x);
     float atanf(float x);
     long double atanl(long double x);

     double atan2(double y, double x);
     float atan2f(float y, float x);
     long double atan2l(long double y long double x);

     double cos(double x);
     float cosf(float x);
     long double cosl(long double x);

     double sin(double x);
     float sinf(float x);
     long double sinl(long double x);

     double tan(double x);
     float tanf(float x);
     long double tanl(long double x);

     #include <complex.h>

     double complex cacos(double complex z);
     float complex cacosf(float complex z);
     long double complex cacosl(long double complex z);

     double complex casin(double complex z);
     float complex casinf(float complex z);
     long double complex casinl(long double complex z);

     double complex catan(double complex z);
     float complex catanf(float complex z;
     long double complex catanl(long double complex z);

     double complex ccos(double complex z);
     float complex ccosf(float complex z);
     long double complex ccosl(long double complex z);

     double complex csin(double complex z);
     float complex csinf(float complex z);
     long double complex csinl(long double complex z);

     double complex ctan(double complex z);
     float complex ctanf(float complex z;
     long double complex ctanl(long double complex z);

DESCRIPTION
     The complex functions are available only in libm and libmx for
     programs compiled with -n32 or -64.

     The single-precision and long double-precision routines listed above
     are only available in the standard math library, -lm, and in -lmx.

     Alternate entries exist for several routines.  The following lists
     those routines with their ANSI standard name and the alternate entry
     name:

     ANSI standard name       Alternate name

     sinf                     fsin

     asinf                    fasin

     cosf                     fcos

     acosf                    facos

     atanf                    fatan

     tanf                     ftan

     atan2f                   fatan2

     cosl                     qcos

     acosl                    qacos

     asinl                    qasin

     atanl                    qatan

     atan2l                   qatan2

     sinl                     qsin

     tanl                     qtan

     sin, cos and tan return trigonometric functions of radian arguments x
     for double data types.  sinf, cosf and tanf return trigonometric
     functions of radian arguments x for float data types.  sinl, cosl and
     tanl do the same for long double data types.

     The asin routines return the inverse sine in the range -pi/2 to pi/2.
     The type of both the return value and the single argument are double
     for asin, float for fasin and its ANSI-named counterpart asinf, and
     long double for asinl.

     The casin functions return the complex inverse sine value.  The csin
     functions return the complex sine value.

     The acos routines return the inverse cosine in the range 0 to pi.  The
     type of both the return value and the single argument are double for
     acos, float for facos and its ANSI-named counterpart acosf, and long
     double for acosl.

     The ccos functions compute the complex cosine of z.  The cacos
     functions return the complex inverse cosine value.

     The atan routines return the inverse tangent in the range -pi/2 to
     pi/2.  The type of both the return value and the single argument are
     double for atan, float for fatan and its ANSI-named counterpart atanf,
     and long double for atanl.

     The atan2 routines return the inverse tangent of y/x in the range -pi
     to pi using the signs of both arguments to determine the quadrant of
     the return value.  Both the return value and the argument types are
     double for atan2, float for fatan2 and its ANSI-named counterpart
     atan2f, and long double for atan2l.

     The ctan functions compute the complex tangent of z. The catan
     functions compute the complex inverse tangent of z.

NOTES
     Functions in the standard math library (libm.a) are referred to as
     -lm; functions in the the BSD math library (libm43.a) are referred to
     as -lm43 versions.

     The -lm versions always return the default Quiet NaN and set errno to
     EDOM when a NaN is used as an argument.  A NaN argument usually causes
     the -lm43 versions to return the same argument.  The -lm43 versions
     never set errno.

     If |x| > 1, the -lm versions of the asin and acos functions set errno
     to EDOM and return NaN. When the argument is greater than one, the
     return value of the -lm43 versions is indeterminate.

     The atan2 functions  return zero if both arguments are zero.  The -lm
     versions also set errno to EDOM.  An exception is the -lm43 versions,
     which return the following results:

          atan2(0.0, 0.0) = 0.0
          atan2(-0.0, 0.0) = -0.0
          atan2(0.0, -0.0) = pi

     This matches the proposed ANSI C9X Standard.

      The -lm versions also set errnor to EDOM for these arguments.

     See matherr(3M) for a description of error handling for -lmx
     functions.

     The single precision routines fsin, fcos, and ftan are accurate to
     within 1 ULP for arguments in the range -2**22 to 2**22.  Double
     precision routines sin, cos, and tan are accurate to within 2 ULP for
     arguments in the range -2**28 to 2**28.  Arguments larger than this
     lose precision rapidly, but retain more than 20 bits precision out to
     +/-2**50 for the double routines.

     Long double operations on this system are only supported in round to
     nearest rounding mode (the default).  The system must be in round to
     nearest rounding mode when calling any of the long double functions,
     or incorrect answers will result.

     Users concerned with portability to other computer systems should note
     that the long double and float versions of these functions were
     optional according to the ANSI C Programming Language Specification
     ISO/IEC 9899 : 1990 (E) and are no longer optional according to
     ISO/IEC 9899: 1999(E).

     Long double functions are named to be compliant with the ANSI-C
     standard; however, to be backward compatible, they may still be called
     with the double precision function name prefixed with a q.

     The following are reasons for assigning a value to atan2(0,0):

     * 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.

     * atan2 is used mostly to convert from rectangular (x,y) to polar
       (r,theta) if 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).  In general, conversions to polar
       coordinates should be computed as follows:

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

     * The previous formulas do not have to be altered to cope in a
       reasonable way with signed zeros and infinities on machines, such as
       SGI 4D machines, that conform 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.

       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);

     This is the case 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.

SEE ALSO
     math(3M), hypot(3M), sqrt(3M), matherr(3M)

     The Fortran version of these routines:
     sin(3F), cos(3F), tan(3F), asin(3F), acos(3F), atan(3F), atan2(3F)