In numerical analysis, the Horner scheme (also known as Horner algorithm), named after William George Horner, is an algorithm for the efficient evaluation of polynomials in monomial form. Horner's method describes a manual process by which one may approximate the roots of a polynomial equation. The Horner scheme can also be viewed as a fast algorithm for dividing a polynomial by a linear polynomial with Ruffini's rule.
Contents
Description of the algorithm
Given the polynomial
where are real numbers, we wish to evaluate the polynomial at a specific value of x, say x_{0}.
To accomplish this, we define a new sequence of constants as follows:
Then b_{0} is the value of p(x_{0}).
To see why this works, note that the polynomial can be written in the form
Thus, by iteratively substituting the b_{i} into the expression,
Examples
Evaluate for . By repeatedly factoring out x, f_{1} may be rewritten as . We use a synthetic diagram to organize these calculations and make the process faster.
x₀│ x³ x² x¹ x⁰
3 │ 2 6 2 1
│ 6 0 6
└────────────────────────
2 0 2 5
The entries in the third row are the sum of those in the first two. Each entry in the second row is the product of the xvalue (3 in this example) with the thirdrow entry immediately to the left. The entries in the first row are the coefficients of the polynomial to be evaluated. The answer is 5.
As a consequence of the polynomial remainder theorem, the entries in the third row are the coefficients of the seconddegree polynomial that is the quotient of f_{1}/(x3). The remainder is 5. This makes Horner's method useful for polynomial long division.
Divide by :
2 │ 1 6 11 6
│ 2 8 6
└────────────────────────
1 4 3 0
The quotient is .
Let and . Divide by using Horner's scheme.
2 │ 4 6 0 3 │ 5
────┼──────────────────────┼───────
1 │ 2 2 1 │ 1
│ │
└──────────────────────┼───────
2 2 1 1 │ 4
The third row is the sum of the first two rows, divided by 2. Each entry in the second row is the product of 1 with the thirdrow entry to the left. The answer is
[edit] Floating point multiplication and division
Horner's method is a fast, codeefficient method for multiplication and division of binary numbers on a microcontroller with no math coprocessor. One of the binary numbers to be multiplied is represented as a trivial polynomial, where, (using the above notation): a_{i} = 1, and x = 2. Then, x (or x to some power) is repeatedly factored out. In this binary numeral system (base 2), x = 2, so powers of 2 are repeatedly factored out.
[edit] Example
For example, to find the product of two numbers, (0.15625) and m:
[edit] Method
To find the product of two binary numbers, "d" and "m".
 1. A register holding the intermediate result is initialized to (d).
 2. Begin in (m) with the least significant (rightmost) nonzero bit,
 2b. Count (to the left) the number of bit positions to the next most significant nonzero bit. If there are no moresignificant bits, then take the value of the current bit position.
 2c. Using that value, perform a rightshift operation by that number of bits on the register holding the intermediate result
 3. If all the nonzero bits were counted, then the intermediate result register now holds the final result. Otherwise, add (d) to the intermediate result, and continue in step #2 with the next most significant bit in (m).
[edit] Derivation
In general, for a binary number with bit values: (d_{3}d_{2}d_{1}d_{0}) the product is:
 (d_{3}2^{3} + d_{2}2^{2} + d_{1}2^{1} + d_{0}2^{0})m = d_{3}2^{3}m + d_{2}2^{2}m + d_{1}2^{1}m + d_{0}2^{0}m
At this stage in the algorithm, it is required that terms with zerovalued coefficients are dropped, so that only binary coefficients equal to one are counted, thus the problem of multiplication or division by zero is not an issue, despite this implication in the factored equation:
Full article ▸
