Keywords: evaluating polynomials, nested multiplication
It had been said that the more basic the operations are, the more we can stand to gain by doing it efficiently. Addition and multiplication may be the most basic operations to us all, and so is their combination, the polynomials. Many functions, however, complicated they are, can be approximated by a polynomial. For instance: can be approximated by
their curves are like these:
All figures above show how sophisticated polynomials are approximated. However, How to get this polynomial is not the things we will concern in the class, and what we should worry about is how to compute the formula (1) more efficiently.
We, now, change our polynomial (1) to a general one which contains entries of all distinct integer exponents:
What we gonna do is to find the best way to evaluate polynomial (2) at . Assuming that, the coefficients of the polynomial and the number are always stored in memory or even registers, which is to say that we will not take the transportation time into account.
However, How to measure the efficiency of evaluating is a new problem coming to our faces, however, I got two ways to solve this problem:
The first one is to count the ticks of the entire process, which is in the view of time. For instance, if our algorithm has taken 10 seconds, and the state-of-art algorithm have taken 11 seconds, Our algorithm would be the best for now.
The second is to count the total quantity of the operations of the algorithm, such as, if our algorithm has had 10 multiplications and 5 additions, while the state-of-art algorithm has had 11 multiplications and 5 additions, our algorithm would be better.
In this section, we will measure the efficiency of the algorithm through the second way, count the quantity of the operations.
Now, we go back to our main problem of finding out the best way to evaluate:
In a usual way, we will calculate
There are multiplications and additions(the subtraction here is regarded as the same as addition).
Method one has 10 multiplications and 4 additions.
Smart readers may have found that we have done ‘’ more times than necessary, while, some result can be stored in the memory instead of computing again and again, which will save many resources of computation. So the method becomes:
That is to say has one multiplication, and has two multiplications, while the has two multiplications as well. So there totally are multiplications and 4 additions(the subtraction here is regarded as the same as an addition).
Method two has 7 multiplications and 4 additions.
Rewrite the polynomial as:
When , we evaluate the polynomial from the inside out:
This method is called nested multiplication or Horner’s method, in which there are 4 multiplications and 4 additions. A general degree polynomial can be evaluated in multiplications and additions.
The example of polynomial evaluation is characteristic of the entire topic of computational methods for scientific computing. While the standard form for a polynomial can be written in nested form as:
In chapter 3 we will require the form：
where we call and the base points. when we set , formula (0.8) is recovered to formula (0.7).
Polynomial can be evaluated in a very efficient way through nested multiplication. But, what is more important for us in this subject are these:
Computers are very fast at doing very simple things.
It’s important to do even simple tasks as efficiently as possible.
The best way may not be the obvious way.
- Sauer, T., Columbus, B., New, I., San, Y., Upper, F., River, S., … Tokyo, T. (n.d.). Numerical Analysis. Retrieved from http://www.pearsoned.com/legal/permissions.htm.