Sin(huge)

The computation of exhibits argument reduction and the issues of assigning mathematical meaning to floating-point results. Assume that Sin(0x1.0p127f) is computed entirely in the float format. First, because sin is periodic with period , use the identity to reduce the argument to the range by casting off multiples of . Then use identities such as , , and to reduce the computation to evaluating sin or cos over the range .

To compute the float value , the transcendental value is rounded to the float value --called P here--for argument reduction. The period of Sin is instead of . Once you have determined the period, the Remainder function is ideal for the argument reduction. Passed the two float arguments 0x1.0p127f and (0x0.C90FDBp1f), Remainder carries out the division of the huge value by , until it has produced all of the integer quotient bits-- --and the first fraction quotient bit. What remains after this very long division is an exact float remainder, , no greater in magnitude than . That is:

Use the identities to reduce the computation to . The only error committed before the actual computation of Cos of the reduced argument is the rounding of .

Sin is periodic, but with the wrong period, and the effect is to phase shift large arguments. In this artificial example the argument is a huge integer with no significant bits smaller in magnitude than . For such large arguments, the computed Sin is completely different from mathematical sin. But the accuracy of Sin and Cos over the range and their periodicity over the whole number system make them useful for a variety of applications where large arguments can arise.


[Contents] [Previous] [Next]
Click the icon to mail questions or corrections about this material to Taligent personnel.
Copyright©1995 Taligent,Inc. All rights reserved.

Generated with WebMaker