> Looks like a Taylor series to me. It isn't a terrible
> algorithm; looks pretty clean actually.
The terms of this polynomial have the same exponents for x as the
Taylor series; the coefficients are probably different.
The reason for this is that a Taylor series gets to be a better
approximation to the _complete_ sine function _when the sum acquires
more terms_. The goal for the finite series of the sine code is a
different one, namely to approximate the sine function as well as
possible on the interval [0,pi/4] _given the seven terms_.
One way to obtain its coefficients is to minimise the distance
between the approximation and the "real" sine function - for
instance by using the absolute value expression that David copied
from the comments. That's also where the criterion for "double
precision" is fixed - it is in the requirement that that expression
is less than 2**(-58). I think that for single precision you could
ease this to 2**(-29) or perhaps 2**(-28). Subsequently, you'll
have to determine how many terms you can drop from the series, and
what the new (optimal) coefficients are.
Seems like a lot of work, but doable, especially when the authors
of this code indicated what method they used to arrive at the
coefficients. I don't think, however, that you can get a factor of
two speedup this way.
Cheers,
Toon.
-- To unsubscribe: send e-mail to axp-list-request@redhat.com with 'unsubscribe' as the subject. Do not send it to axp-list@redhat.com
Copyright © 1995-1997 Red Hat Software. Legal notices