trig(3M)
NAME
sin, cos, tan, asin, acos, atan, atan2, sinf, cosf, tanf, asinf, acosf, atanf, atan2f − trigonometric functions
SYNOPSIS
#include <math.h>
double sin (x)
double x;
double cos (x)
double x;
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 x, y;
For Series 1000, 3000, and 4000 Systems:
float sinf (float x)
float cosf (float x)
float tanf (float x)
float asinf (float x)
float acosf (float x)
float atanf (float x)
float atan2f (float y, float x)
DESCRIPTION
Sin, sinf, cos, cosf, tan, and tanf return, respectively, the sine, cosine, and tangent of their argument, x, measured in radians.
Asin and asinf return the arcsine of x, in the range −PI/2 to PI/2.
Acos and acosf return the arccosine of x, in the range 0 to PI.
Atan and atanf return the arctangent of x, in the range −PI/2 to PI/2.
Atan2 and atan2f return the arctangent of y/x, in the range −PI to PI, using the signs of both arguments to determine the quadrant of the return value.
DIAGNOSTICS
For the double precision functions: Sin, cos, and tan lose accuracy when their argument is far from zero. For arguments sufficiently large, these functions generate a TLOSS error when there would be a complete loss of significance. For less extreme arguments causing partial loss of significance, a PLOSS error is generated.
| SIN,COS: | result | errno | |
| total loss | 0.0 | ERANGE | TLOSS error message |
| partial loss | sin(x),cos(x) | ERANGE | no message |
| x = infinity | qNaN | EDOM | no message |
| x = NaN | qNaN | EDOM | no message |
| TAN: | result | errno | |
| total loss | 0.0 | ERANGE | TLOSS mess. |
| partial loss | tan(x) | ERANGE | no message |
| x ~ pi/2 (Ser 1000, 3000, 4000) | +infinity | EDOM | no message |
| x = infinity | qNaN | EDOM | no message |
| x = NaN | qNaN | EDOM | no message |
| ASIN,ACOS: | result | errno | |
| |x| > 1 | 0.0 | EDOM | DOMAIN error message |
| x = infinity | qNaN | EDOM | no message |
| x = NaN | qNaN | EDOM | no message |
| ATAN: | result | errno | |
| x = +infinity | +pi/2 | not set | no message |
| x = -infinity | -pi/2 | not set | no message |
| x = NaN | qNaN | EDOM | no message |
| ATAN2: | result | errno | |
| x = 0.0, y = 0.0 | 0.0 | EDOM | DOMAIN error |
| x = 0.0, y < 0.0 | -pi/2 | not set | no message |
| x = 0.0, y > 0.0 | +pi/2 | not set | no message |
| x < 0.0, y = 0.0 | +pi | not set | no message |
| x > 0.0, y = 0.0 | 0.0 | not set | no message |
| overflow, y < 0.0 | -pi/2 | not set | no message |
| overflow, y > 0.0 | +pi/2 | not set | no message |
| underflow, x > 0.0 | 0.0 | not set | no message |
| underflow, x < 0.0, y < 0.0 | -pi | not set | no message |
| underflow, x < 0.0, y > 0.0 | +pi | not set | no message |
| x = infinity | qNaN | EDOM | no message |
| x = NaN or y = NaN | qNaN | EDOM | no message |
These error-handling procedures may be changed with the matherr(3M) function, if the program is not linked in the ANSI C conforming mode (−Xc). See hc(1) for more information about compilation modes.
If the program is linked one of the ANSI C compilation modes, messages will not be produced under any circumstances.
For the single precision functions: Sinf, cosf, and tanf lose accuracy when their argument is far from zero. For arguments sufficiently large, these functions generate a TLOSS error when there would be a complete loss of significance. For less extreme arguments causing partial loss of significance, a PLOSS error is generated.
| SINF,COSF: | result | errno | |
| total loss | qNaN | EDOM | no message |
| x = infinity | qNaN | EDOM | no message |
| x = NaN | qNaN | EDOM | no message |
| TANF: | result | errno | |
| total loss | qNaN | TLOSS | no message |
| partial loss | tanf(x) | PLOSS | no message |
| x ~ pi/2 | +infinity | DOMAIN | no message |
| x = infinity | qNaN | DOMAIN | no message |
| x = NaN | qNaN | DOMAIN | no message |
| ASINF,ACOSF: | result | errno | |
| |x| > 1 | qNaN | DOMAIN | no message |
| x = infinity | qNaN | DOMAIN | no message |
| x = NaN | qNaN | DOMAIN | no message |
| ATANF: | result | errno | |
| x = +infinity | +pi/2 | not set | no message |
| x = -infinity | -pi/2 | not set | no message |
| x = NaN | qNaN | EDOM | no message |
| ATAN2F: | result | errno | |
| x = 0.0, y = 0.0 | qNaN | DOMAIN | no message |
| x = 0.0, y < 0.0 | -pi/2 | not set | no message |
| x = 0.0, y > 0.0 | +pi/2 | not set | no message |
| x < 0.0, y = 0.0 | +pi | not set | no message |
| x > 0.0, y = 0.0 | 0.0 | not set | no message |
| overflow, y < 0.0 | -pi/2 | not set | no message |
| overflow, y > 0.0 | +pi/2 | not set | no message |
| underflow, x > 0.0 | 0.0 | not set | no message |
| underflow, x < 0.0, y < 0.0 | -pi | not set | no message |
| underflow, x < 0.0, y > 0.0 | +pi | not set | no message |
| x = infinity | qNaN | EDOM | no message |
| x = NaN or y = NaN | qNaN | EDOM | no message |
If the program is linked in one of the ANSI C compilation modes, tanf, asinf, acosf, and atan2f will set errno to EDOM instead of DOMAIN for domain errors.
The matherr(3M) function has no effect on the single precision functions.
PERFORMANCE IMPROVEMENTS
These functions check the integrity of their arguments for mathematical validity and conformance to the IEEE Floating-Point Arithmetic standard’s definition of numbers. They also maintain high accuracy of computations through occasional use of higher precision arithmetic and lengthier computations designed to minimize round-off errors. The library libm.a contains these robust functions. An alternate math library, libM.a, offers increased performance at the expense of argument checking and accuracy. The checks for mathematical validity and IEEE numbers are not performed on these functions in this additional library. Checks at the boundary conditions of minimum and maximum representable values, however, are conducted. The accuracy losses are usually never more than 1-bit differences when compared with the robust versions. This alternate library is intended for use when the characteristics of the arguments are well-understood and higher performance is preferred over increased accuracy. One consequence of these less-robust functions is that erroneous arguments are not caught and may produce meaningless answers.
SEE ALSO
CX/UX Programmer’s Reference Manual