Oracle® Solaris Studio 12.4: Numerical Computation Guide
Updated: January 2015

### 3.6.2 Argument Reduction for Trigonometric Functions

Trigonometric functions for radian arguments outside the range [–π/4,π/4] are usually computed by reducing the argument to the indicated range by subtracting integral multiples of π/2.

Because π is not a machine-representable number, it must be approximated. The error in the final computed trigonometric function depends on the rounding errors in argument reduction with an approximate π as well as the rounding, and approximation errors in computing the trigonometric function of the reduced argument. Even for fairly small arguments, the relative error in the final result might be dominated by the argument reduction error, while even for fairly large arguments, the error due to argument reduction might be no worse than the other errors.

There is widespread misapprehension that trigonometric functions of all large arguments are inherently inaccurate, and all small arguments relatively accurate. This is based on the simple observation that large enough machine-representable numbers are separated by a distance greater than π.

There is no inherent boundary at which computed trigonometric function values suddenly become bad, nor are the inaccurate function values useless. Provided that the argument reduction be done consistently, the fact that the argument reduction is performed with an approximation to π is practically undetectable, because all essential identities and relationships are as well preserved for large arguments as for small.

libm and libsunmath trigonometric functions use an “infinitely” precise π for argument reduction. The value 2/π is computed to 916 hexadecimal digits and stored in a lookup table to use during argument reduction.

The group of functions sinpi, cospi, and tanpi (see Table 3–3) scales the input argument by π to avoid inaccuracies introduced by range reduction.