Estrin's scheme


In numerical analysis, Estrin's scheme, also known as Estrin's method, is an algorithm for numerical evaluation of polynomials.
Horner's method for evaluation of polynomials is one of the most commonly used algorithms for this purpose, and unlike Estrin's scheme it is optimal in the sense that it minimizes the number of multiplications and additions required to evaluate an arbitrary polynomial. On a modern processor, instructions that do not depend on each other's results may run in parallel. Horner's method contains a series of multiplications and additions that each depend on the previous instruction and so cannot execute in parallel. Estrin's scheme is one method that attempts to overcome this serialization while still being reasonably close to optimal.

Description of the algorithm

Estrin's scheme operates recursively, converting a degree-n polynomial in x to a degree- polynomial in x2 using independent operations.
Given an arbitrary polynomial P = C0 + C1x + C2x2 + C3x3 + ⋯ + Cnxn, one can group adjacent terms into sub-expressions of the form and rewrite it as a polynomial in x2: P = + x2 + x4 + ⋯ = Q.
Each of these sub-expressions, and x2, may be computed in parallel. They may also be evaluated using a native multiply–accumulate instruction on some architectures, an advantage that is shared with Horner's method.
This grouping can then be repeated to get a polynomial in x4: P = Q = + + + x4 + ⋯ = R.
Repeating this +1 times, one arrives at Estrin's scheme for parallel evaluation of a polynomial:
  1. Compute Di = C2i + C2i+1x for all 0 ≤ i ≤ .
  2. If n ≤ 1, the computation is complete and D0 is the final answer.
  3. Otherwise, compute y = x2.
  4. Evaluate Q = D0 + D1y + D2y2 + ⋯ + Dy using Estrin's scheme.
This performs a total of n multiply-accumulate operations in line 1, and an additional squarings in line 3. In exchange for those extra squarings, all of the operations in each level of the scheme are independent and may be computed in parallel; the longest dependency path is +1 operations long. A similar idea enables a fast matrix multiplication algorithm to evaluate a polynomial at a series of points.

Examples

Take Pn to mean the nth order polynomial of the form: Pn = C0 + C1x + C2x2 + C3x3 + ⋯ + Cnxn
Written with Estrin's scheme we have:
In full detail, consider the evaluation of P15:

In combination with Horner's method

Estrin's full scheme uses a very large number of multiply–accumulate operations in the first step. While this is useful to fully exploit modern superscalar processors, it will eventually exceed the available computing resources, at which point it may be useful to use Estrin's scheme to a limited depth, and then Horner's method on the residual.
For example, if a computer can perform four multiply-accumulate operations before the result of the first operation is available, then two levels of Estrin's scheme will keep its instruction pipeline full. Each iteration, it can perform the following operations in parallel:
The final result is F0.
A more capable processor may be able to have four 4-operand SIMD operations in progress at once, in which case four levels of Estrin's scheme could be used to evaluate a sufficiently high-degree polynomial.