Content deleted Content added
Add evaluation algorithm |
Clean up notation |
||
Line 2:
<!-- Important, do not remove anything above this line before article has been created. -->
The '''Knuth-Eve algorithm''' is an [[algorithm]] for [[polynomial evaluation]]
The key ideas used in this algorithm were originally proposed by [[Donald Knuth]]. His procedure opportunistically exploits structure in the polynomial being evaluated.<ref name="knuth1962"/> Eve determined for which polynomials this structure exists, and they gave a simple method of [[#"Preconditioning"|"preconditioning"]] polynomials to endow them with that structure.<ref name="eve1964"/>
Line 12:
Consider an arbitrary polynomial <math>p \in \mathbb{R}[x]</math> of [[Degree of a polynomial|degree]] <math>n</math>. Assume that <math>n \geq 3</math>. Define <math>m</math> such that: if <math>n</math> is odd then <math>n = 2m+1</math>, and if <math>n</math> is even then <math>n = 2m+2</math>.
Unless otherwise stated, all variables represent either [[Real number|real numbers]] or univariate [[Polynomial|polynomials]] with real coefficients. All operations are done over <math>\mathbb{R}</math>.
Again, the goal is to create an algorithm that returns <math>p(x)</math> given any <math>x</math>. The algorithm is allowed to depend on the polynomial <math>p</math> itself.
Line 24:
<math display="block"> p(x) = q(x) \cdot (x^2 - \alpha) + (\beta x + \gamma), </math>
where <math>x^2 - \alpha</math> is the divisor. Picking a value for <math>\alpha</math> fixes both the quotient <math>q</math> and the coefficients in the remainder <math>\beta</math> and <math>\gamma</math>.
<math display="block"> p(x) = q(x) \cdot (x^2 - \alpha) + \gamma. </math>
<math display="block"> p(x) = \left( \left(
After <math>m</math> recursive calls, the quotient <math>
==== "Preconditioning" ====
For arbitrary <math>p</math>, it may not be possible to force <math>\beta = 0</math> at every step of the recursion.<ref name="knuth1962"/>
<math display="block"> p(x) = p^e(x^2) + x \cdot p^o(x^2). </math>
Line 42:
If every [[Zero of a function#Polynomial roots|root]] of <math>p^o</math> is real, then it is possible to write <math>p</math> in the form given above. Each <math>\alpha_i</math> is a different root of <math>p^o</math>, counting [[Multiplicity (mathematics)#Multiplicity of a root of a polynomial|multiple roots]] as distinct.<ref name="overill1997"/> Furthermore, if all the roots of <math>p</math> (except perhaps one) lie in one half of the [[Complex number|complex plane]], then every root of <math>p^o</math> is real.<ref name="eve1964"/>
Ultimately, it may be necessary to "precondition" <math>p</math> by shifting it {{--}} by setting <math>p(x) \gets p(x + t)</math> for some <math>t</math> {{--}} 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 <math>x \gets x - t</math>.
=== Preprocessing step ===
The following algorithm is run once for a
At this point, the values of <math>x</math> that <math>p</math> will be evaluated on are not known.
Line 53:
{{framebox|blue}}
* Let <math>r_1, \cdots, r_n \in \mathbb{C}</math> be the complex roots of <math>p</math>
* Let <math display="inline">t = \max_{i = 1}^n \text{Re}(r_i)</math
*
<hr/>
* Let <math>
* Let <math>\alpha_1, \cdots \alpha_m \in \mathbb{R}</math> be all the roots of <math>p^o</math>. All of its roots will be real.
<hr/>
* Initialize <math>q \gets p</math>
* For <math>i \gets 1, \cdots, m</math>:
** Divide <math>
** Set <math>q \gets q^\prime</math>
<hr/> * ''Output:'' The derived values <math>t</math>, <math>\alpha_1, \cdots, \alpha_m</math>, and <math>\gamma_1, \cdots, \gamma_m</math>; as well as the base-case polynomial <math> {{frame-footer}}
</div>
Line 65 ⟶ 70:
=== Evaluation step ===
The following algorithm evaluates <math>p</math> at some, now known, point <math>x</math>. It consumes the output of the [[#Preprocessing step|preprocessing step]].
<div style="margin-left: 35px;">
{{framebox|blue}}
*
* Let <math>s =
<hr/> * Compute <math>
* For <math>i \gets m, \cdots, 2, 1</math>:
** Let <math>
* ''Output:'' <math>
{{frame-footer}}
</div>
|