Horner's Method, also know as Horner's rule, is a method for calculating the value of any nth degree polynomial using only n multiplications and n additions. This is achieved through gratuitous use of the properties of distribution and associativity. It was William Horner's only significant contribution to the realm of mathematics, first submitted to the Royal Society in July 1, 1819. He was not however not the first mathematician to have developed it. Original credit goes to Chu Shih-Chieh, who had known of it approximately 500 years earlier.
Essentially, this rule provides an efficient computational method for calculating the value of a polynomial. The nth degree polynomial is most commonly written as:
f(x) = anxn + an-1xn-1 + ... + a1x + a0
Rather than unnecessarily recompute the powers of x repeatedly, we start from the highest coefficient and work our way down, repeatedly multiplying by x, what this gives us is:
f(x) = ((((((anx + an-1)x + an-2)x) ... + a1)x + a0
The following C function will also compute the value of a polynomial using Horner's Method:
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;
}
The really cool thing about Horner's rule is that it allows us to parallelize the computation. By using multiple variables to store the values, we can compute the polynomial by multiplying by some small power of x rather than using x itself. Say we use two temporary variables, the first will store the computation for every even power of x, and the second for every odd power. Since the two are not dependent on each other, we can do both at once, and then add the result at the end. |