Summary: Horner's method is a standard minimum arithmetic method for evaluating and deflating polynomials. It can also efficiently evaluate various order derivatives of a polynomial, therefore is often used as part of Newton's method. This note tries to develop the various techniques called Horner's method, nested evaluation, and synthetic division in a common framework using a recursive structure and difference equations. There is a similarity to Goertzel's algorithm for the DFT, Z-transform inversion by division, and Pade's and Prony's methods. This approach also allows a straight forward explanation of "stability" or numerical errors of the algorithms. Matlab implementations are given. This note came from the work of the "Polynomial Club" at Rice: Burrus, Fox, Sitton, and Treitel.
Polynomials are one of the oldest classes of mathematical functions with an important history in mathematics, science, engineering, and other quantitative fields [1]. Part of the polynomial's appeal comes from the fact that it may be numerically evaluated using a finite number of multiplications and additions. In the processes of factoring, evaluating, and deflating polynomials, Horner's methods are central and are the focus of this note.
Any Nth degree polynomial can be written in coefficient form as:
can be written in a nested form as:
or nested in a different order as:
and in a factored form as:
where
The polynomial can be written in a first order remainder form as:
where
is the quotient polynomial obtained when
If
roots()
poly()
polyval()
Horner's methods are important for evaluation and deflation, therefore, for factoring. For many high degree polynomial factoring schemes, it is important to use stable evaluation and deflation and to deflate in an order that maximizes the conditioning of the quotient. Unfactoring is simply the multiplying of the factors to obtain the polynomial but, because of round-off error, the order of multiplication is important. As an alternative, the FFT/DFT can be used to unfactor and evaluate. Of the four, only factoring is nonlinear and it is the most difficult. In many strategies, factoring uses the other three. For implementation of any of the four, the number of arithmetic operations required will determine the speed of execution and stability and conditioning will affect the error characteristics.
From the structure of the nested forms in (2) and (3), one can formulate a recursive relation which is also a linear first order difference equation:
for
|
Remember that Matlab stores polynomial coefficients in the reverse order of the notation used by many writers and the reverse of that shown in (1) and starts indexing with 1 rather than 0.
This formulation is very efficient if implemented with the "multiplicity-accumulate" single-cycle instruction of several DSP chips and some microprocessors.
The nested forms of (2) and (3), the remainder form of (5), and the recursive from of (9) are all versions of Horner's method [2,5,6] or synthetic division. There are also similarities to the Goertzel algoirthm to evaluate the DFT, the Padé or Prony method and inversion of z-transforms by division. Indeed, all of these methods convert an evaluation into a recursion and then into a difference equation which has considerable literature [7]. While in some cases it is possible to reduce the number of multiplications used by Horner in polynomial evaluation, it is generally a small gain and accompanied by an increase in the number of additions and the complexity of the algorithm. If preprocessing of the polynomial coefficients is not used, Horner gives a minimum arithmetic evaluation [3,5].
If we differentiate (5), we get:
which, if evaluated at
which can be evaluated by a minor variation of (9). Thus Horner's method can evaluate an Nth degree polynomial with N multiplications and additions or evaluate it and its derivative with 2N multiplications and additions or avaluate it and its derivative with 2N multiplications and additions. Note
|
This can be made much faster by using the filter() function in Matlab as:
|
From (11) and (6), we see that the value of the derivative of the Nth degree polynomial
which has the same form as (9) but saving the intermediate values of
A similar argument shows that solving (12) with an input of
which is a power series expansion [5] around
The following program evaluates the function and its first and second derivatives in a very compact single loop solution of the basic first order difference equation without saving the coefficients
|
Higher order derivatives can be evaluated by a simple extension of this idea.
Describing the algorithm as a flow-graph illustrates the recursion as a feedback path with the feedback parameter being
|
If
with
|
or using the more efficient Matlab "filter" command:
|
Because multiplication of two polynomials is the same operation as the convolution of their coefficients, one can get the same results by multiplying the discrete Fourier transform (DFT)'s of the polynomial coefficients and taking the inverse DFT of the product. This gives an alternative to Horner's algorithm for deflating polynomials and is the technique used in the Lindsey-Fox polynomial factoring scheme [8, 2]. The use of the FFT for deflation or unfactoring of polynomials has very different error characteristics from Horner's method and is often superior. A Matlab program that deflates a polynomial with coefficients
|
A more general formulaiton of the deflation problem is of the form:
Horner's method is implemented by the recursive equation (9) or (12) which, in this form, is seen to be a linear first order constant coefficient difference equation. There is considerable literature on the stability of linear differential and difference equations [7], and an equation of this form is known to be stable [9] for
To reduce error accumulation when
Again, remembering the Matlab index convention, the program for this form of Horner's algorithm is:
|
The same can be done for deflation.
This algorithm is equivalent to reversing the order ("flipping") the polynomial coefficients and applying (9) which will give zeros that are the reciprocal of those of the original polynomial [6,2]. Using the standard Matlab commands, this can be done by:
|
It is easy to see that stability is very important when evaluating or deflating high degee polynomials by considering the effects if the degree is as high as one million [2]. Using this difference equation formulation of Horner's methods allows a more general deflation using a quadratic or higher degree divisor polynomial based on (8) and (15) to be easily analysed for stability.
We have seen that polynomial evaluation and deflation can be done by Horner's approach which is the conversion of the problem into a linear difference equation. Indeed, evaluation and first order deflation are accomplished by the same algorithm and the stability is easily controlled. Horner's methods are used in several basic Newton type factoring programs such as "broots". The alternative use of the DFT (FFT) for deflation should always be considered.
Having forwards and backwards algorithms allows one to always use a stable evaluation or deflation scheme [10,11,5,12,6,2,9]. If the magnitude of