Jump to content

Draft:Knuth–Eve algorithm

From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Ammrat13 (talk | contribs) at 05:06, 27 July 2025 (Clean up notation). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

The Knuth-Eve algorithm is an algorithm for polynomial evaluation. It preprocesses the coefficients of the polynomial to reduce the number of multiplications required at runtime.

The key ideas used in this algorithm were originally proposed by Donald Knuth. His procedure opportunistically exploits structure in the polynomial being evaluated.[1] Eve determined for which polynomials this structure exists, and they gave a simple method of "preconditioning" polynomials to endow them with that structure.[2]

Algorithm

Preliminaries

Consider an arbitrary polynomial of degree . Assume that . Define such that: if is odd then , and if is even then .

Unless otherwise stated, all variables represent either real numbers or univariate polynomials with real coefficients. All operations are done over .

Again, the goal is to create an algorithm that returns given any . The algorithm is allowed to depend on the polynomial itself.

Overview

Key idea

Using polynomial long division, we can write

where is the divisor. Picking a value for fixes both the quotient and the coefficients in the remainder and . The key idea is to cleverly choose such that , so that

We apply this procedure recursively to , expressing

After recursive calls, the quotient is either a linear or a quadratic polynomial. In this base case, the polynomial can be evaluated with (say) Horner's method.[1]

"Preconditioning"

For arbitrary , it may not be possible to force at every step of the recursion.[1] Consider the polynomials and with coefficients taken from the even and odd terms of respectively, so that

If every root of is real, then it is possible to write in the form given above. Each is a different root of , counting multiple roots as distinct.[3] Furthermore, if all the roots of (except perhaps one) lie in one half of the complex plane, then every root of is real.[2]

Ultimately, it may be necessary to "precondition" by shifting it — by setting for some — to endow it with the structure that all its roots lie in one half of the complex plane. At runtime, this shift has to be "undone" by first setting .

Preprocessing step

The following algorithm is run once for a given polynomial . Its results are used by the evaluation step, and they can be reused across many calls to that step.

At this point, the values of that will be evaluated on are not known.

  • Let be the complex roots of
  • Let
  • Set

  • Let and be the polynomials such that
  • Let be all the roots of . All of its roots will be real.

  • Initialize
  • For :
    • Divide by to get quotient and remainder . The remainder will be a constant polynomial — a number.
    • Set

  • Output: The derived values , , and ; as well as the base-case polynomial

Evaluation step

The following algorithm evaluates at some, now known, point . It consumes the output of the preprocessing step.

  • Set
  • Let . Compute this once so it can be reused throughout the algorithm.

  • Compute using Horner's method
  • For :
    • Let
  • Output:

Notes

  1. ^ a b c Knuth, Donald (December 1962). "Evaluation of polynomials by computer". Communications of the ACM. 5 (12): 595–599. doi:10.1145/355580.369074. Retrieved 25 July 2025.
  2. ^ a b Eve, J. (December 1964). "The evaluation of polynomials". Numerische Mathematik. 6 (1): 17–21. doi:10.1007/BF01386049. Retrieved 25 July 2025.
  3. ^ Overill, Richard (12 June 1997). "Data parallel evaluation of univariate polynomials by the Knuth-Eve algorithm". Parallel Computing. 23 (13): 2115–2127. doi:10.1016/S0167-8191(97)00096-3. Retrieved 25 July 2025.

References