next up previous contents
Next: Sample Program Up: Taylor Polynomials Previous: Applications   Contents

Polynomial Evaluation

We discuss now the computational cost for evaluating the Taylor polynomial value at some point


When evaluating the compiler (usually) translates it to multiplications. Thus, the naive algorithm

p = b(0)
do i=1,n
  p = p + b(i)*x**i
end do
will require additions and , i.e. multiplications.

A better alternative is to save the computed power of from one iteration to the next. Since , iteration will need just two multiplications (not ) to compute .

p = b(0)
powx = 1.0
do i=1,n
  powx = powx*x     ! powx = x**i
  p = p + b(i)*powx
end do
This second algorithm needs additions and multiplications.

We can do even better than this, by rewriting the polynomial in nested form


We have to start with the last term and loop back to the first. The algorithm goes as follows

p = b(n)
do i=n-1,0,-1
  p = b(i) + x*p
end do

and requires additions and only multiplications.





Adrian Sandu 2001-08-26