Per a note from Ian Ollman, viz.:
"
I'm not a very big fan of lookup tables though. I have found I can
evaluate a 9th order polynomial in hand tuned vector code in less time
than it takes to look up results from a 256 entry float table using
hand tuned scalar code.
"
it is interesting that, now with G4/G5 power, techniques known for
50 (FIFTY) years gain relevance. For example, on the posed problem
of taking cos() on every float in a large array, consider Ollman's
observation
in regard to polynomial finite-degree formulae for cosine. One such
is
cos(x) ~ 1 + a[2] x^2 + a[4] x^4 + ... + a[10] x^10
(which is actually, of course, a degree-5 polynomial, in x^2), where
the
coefficients a[2n] are given on p. 76 of the classic Abramowitz &
Stegun
(this is available on-line at
http://jove.prohosting.com/~skripty/page_76.htm).
Accurate to > 8 decimal places on x \in (0,PI/2), this is from 1955, and
has been
used in puny hand-held calculators.
Obviously vectorizable---in several ways---and Ian's observation means
that this is probably the "unbeatable" approach to "good" cosine
evaluation on large arrays. There may be a quicker formula, but the
basic idea of doing pure algebra over the array, instead of doing
function calls per se, is probably "boss."
Incidentally, the reason one needs only x \in (0,PI/2) is that the
trigonometric
functions' shapes are just tesselations of the shapes of their curves in
said
restricted interval (0,PI/2).
R. E. Crandall
Advanced Computation Group
_______________________________________________
scitech mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/scitech
Do not post admin requests to the list. They will be ignored.