… and a better solution for quadratics.
Having written a better solver for high order polynomials, that raises a few other issues. The error in the roots found by the RPolyJT was checked by simply substituting each root as the x value in: ax^n + bx^(n-1) + cx^(n-2) + …+e = 0. The problem is that finding the difference between two similar large numbers significantly reduces the precision of the result. A much better approach is known as the Horner Scheme, which uses Synthetic Division to arrive at the value of the polynomial without subtraction of the values raised to high powers.
This method has now been added to the Polynomial spreadsheet with the following changes:
- RPolyJT has been modified to call the new function EvalErrorHC() to evaluate the error in the roots found.
- EvalErrorHC may also be used as a UDF from the spreadsheet.
- EvalPolyHC will evaluate any polynomial for a list of values of x (real or complex), which may take any value (i.e. not necessarily estimated roots).
For similar reasons, the standard quadratic formula will not give accurate results when b^2 and 4ac are large and of similar magnitude. Better accuracy is given by a method included in the Fortran code used as the basis of the RPolyJT function. The Quadratic function in the Polynomial spreadsheet has now been revised to use this method.
The revised spreadsheet may be downloaded (including full open source code) from:
Results of the new RPolyJT and EvalErrorHC functions are shown in the screen shot below: