Re: Efficiency of math.h

From: E. Robert Tisdale (E.Robert.Tisdale_at_jpl.nasa.gov)
Date: 02/26/04


Date: Wed, 25 Feb 2004 17:07:41 -0800

*** T. Winter wrote:

> 1. Calculating Taylor coefficients on the fly requires division,

Nonsense! Multiply the Taylor coefficients through
by the least common denominator, sum using Horner's rule
then multiply the result by the inverse of the least common denominator.
All of the coefficients can be calculated using integer multiplication.

> which is on most processors much slower than multiplication.
>
> 2. The number of coefficients required in a Tschebychev approximation
> is less than the number of Taylor coefficients needed.

By one or, at best, two terms.

> For instance, to get a good sine in double precision on [0, pi/2],
> you can use only 6 terms
> of the Tschebychev expansion of (sin(x)/x - 1).
> (This formula to get good relative precision near x = 0.)

Let's suppose that the Taylor series requires 8 terms
to obtain the minimum precision everywhere.
The Tschebychev approximation could be, at best, 25% faster.
But it could easily require much more time to load
the high precision Tschebychev coefficients from memory.
But don't take my word for it.
Implement both and benchmark them against each other.
The winner will be determined by your computer architecture.