EVALUATION OF F(X) USING HORNER'S METHOD

Please note that the material on this website is not intended to be exhaustive.
This is intended as a summary and supplementary material to the required textbook.

Horner's Method is a method of expressing a polynomial f(x) = an xn + an–1 xn–1 + . . . + a2 x2 + a1 x1 + a0 x0 which eliminates all exponentiations.   The elimination of exponentiations, eliminates re-doing some calculations.

In NSD, we have






y ¬ an
for ( i ¬ n – 1 downto 0 )
  y ¬ y * x + ai
  In C++, we have

double Horners ( double coef [ ], int degree, double x )
^ ^ {
^ ^ ^ ^ double y ;
^ ^ ^ ^ int i ;

^ ^ ^ ^ y = coef [ degree ] ;

^ ^ ^ ^ for ( i = degree – 1 ; i >= 0; i – – )
^ ^ ^ ^ ^ ^ {
^ ^ ^ ^ ^ ^ ^ ^ y = y * x + coef [ i ] ;
^ ^ ^ ^ ^ ^ }

^ ^ ^ ^ return ( y ) ;
^ ^ }

© 1994-07-23 cpsm; last update: 2010-01-01 20:26