Horner's method 2026-10-14
Horner's method evaluates a polynomial by nested multiplication, requiring one multiplication and one addition per degree after initialization.
For , start with and compute for . The final value is . Equivalently,This reorganization reuses intermediate results, avoiding separate computation of every power. A dense degree- polynomial takes multiplications and coefficient additions after reading its leading coefficient; special zero coefficients may permit further simplifications.
For our cubic, the coefficient list in descending order is . The zero is important: it occupies the missing term's position. At , the accumulated values areAt , the same operations give , confirming .
The same nested arithmetic evaluates a polynomial and produces the coefficients for division by a linear factor
. Details. The intermediate values do more than evaluate. They are the coefficients of the polynomial quotient in polynomial division by , with the final value as the polynomial remainder. At , the first three values give , soAt , they give , so . This links an efficient numerical calculation with the exact factor theorem.
William George Horner's 1819 paper concerns solving numerical equations by successive approximation. The Royal Society archive records the manuscript and its reading on 1 July 1819; it provides a historical reference for the method's name. [ref]
// Target: geometry-and-topology.bigb
Mixed radix 2026-10-31
A positional representation in which each digit has its own positive integer base. Least-significant-first digits satisfy , and digit has weight . For positions, assume . Repeated Euclidean division by the successive bases converts that integer to digits; a backwards version of Horner's method converts the digits back.
Newton polynomial Created 2026-10-14 Updated 2026-10-18
The Newton polynomial expresses the interpolation polynomial in products that successively vanish at all previously used interpolation nodes. With , the coefficients are divided differences:A triangular divided difference table computes all its coefficients using exactly divisions. The Newton polynomial and the Lagrange polynomial have the same polynomial degree bound and the same nodal values, hence are equal by uniqueness of polynomial interpolation.
For , , , the complete divided difference table isThe first divided differences are and , and their divided difference is . Reading the top entries givesThe initial term fits ; adding also fits ; adding fits while leaving the first two data values unchanged. This is the practical beauty of the Newton polynomial: each new correction respects all previous interpolation constraints.
If a new distinct interpolation node with value arrives, append one term:For example, appending to the three-point data gives , hence . Changing the order of the interpolation nodes changes the Newton polynomial coefficients and products, but not the final interpolation polynomial in exact arithmetic.
The products also permit nested evaluation analogous to Horner's method. If , start with and work backwards by ; the answer is . The three-point example becomes , needing two multiplications for each evaluation. This organization is useful when adding observations incrementally or evaluating a stored Newton polynomial many times; the Runge phenomenon still depends on the interpolation nodes rather than on which representation is used.
To justify the update formula, its added product vanishes at every previous interpolation node. Choosing by the new residual forces agreement at , so uniqueness of polynomial interpolation identifies the result. For , has polynomial degree at most , and the added product has leading coefficient one. Thus the new coefficient is exactly . The initial state is , with the empty product interpreted as one.[ref]
Appending to the four-point example in divided difference table leaves the Newton polynomial unchanged: , so the new fourth divided difference is zero. If the appended value is instead , the new coefficient isThis polynomial still takes values at the original interpolation nodes, and now takes value at . A zero update is a valid completed step: adding another exact sample of the original polynomial need not increase the polynomial degree.
Past exam of the mathematics course of the University of Cambridge 2008 iii Paper 77 3 ii Solution Created 2026-10-03 Updated 2026-10-14
The Cox-de Boor recurrence and De Boor's algorithm handle nonuniform knots and repeated knots without converting the whole curve. With a tabulated recurrence they require arithmetic after locating the span and use only local control points; a naive recursive basis evaluation wastes work by recomputing the same terms. De Boor's algorithm evaluates the vector directly using affine combinations. Inside the span these are convex combinations, which makes the geometric construction transparent and avoids the cancellation that can occur in a power-basis representation. Basis evaluation is especially useful when the same knots and parameter are shared by many coordinate functions or many curves, since the weights can be reused.
Precomputed power coefficients followed by Horner's method need only arithmetic per coordinate and are attractive for many evaluations within an unchanged span, particularly for fixed-degree uniform B-splines. Coefficient construction has an initial cost, control-point edits require updates to affected spans, and poor scaling of high-degree power coefficients can damage accuracy. Rescaling each span to helps. Bézier curve extraction has a similar initial conversion cost; De Casteljau's algorithm then gives stable local evaluation, subdivision, a convex hull bound and geometric flatness tests useful for rendering and intersection.
Subdivision is convenient when an entire polygonal approximation is wanted: refine only where needed and reuse the hierarchy. It is less economical for a single prescribed parameter and requires a geometric error bound before its approximate point can replace exact evaluation. Span lookup itself costs for sorted arbitrary knots, constant work for a uniform interior span, or amortized constant work for an ordered sequence of sample parameters. Use de Boor for robust general knots, shared basis weights for batches, and precomputed local polynomials or Bézier pieces for repeated interrogation.
Past exam of the mathematics course of the University of Cambridge 2008 iii Paper 77 3 i Solution Created 2026-10-03 Updated 2026-10-14
Write a degree- B-spline as and locate its spline knot span. There are several equivalent exact evaluation methods.
Evaluate the at most nonzero basis functions by the Cox-de Boor recurrence, then form their weighted sum of control points. Alternatively apply De Boor's algorithm directly to the active control points. In a span , initialize and repeatedly interpolate:for and . The last point is ; zero knot intervals are handled by the standard limiting convention or an appropriate neighboring nonempty span.
A third method precomputes the local polynomial coefficients on each span and evaluates them by Horner's method. For a uniform cubic B-spline, a fixed four-by-four basis matrix gives these coefficients. A fourth method uses knot insertion to express the relevant span as a Bézier curve, followed by De Casteljau's algorithm. Both interpolation algorithms also split the curve at the requested parameter. Repeated subdivision supplies arbitrarily accurate polygonal evaluation, although a finite subdivision mesh is generally an approximation rather than the exact requested point. Basis summation, de Boor interpolation, local polynomial evaluation and Bézier extraction are equivalent exact representations.
Use an Oberon record containing an active coefficient count and a bounded array of coefficients in ascending power order. A count of zero represents the zero polynomial; a count represents . Trailing zero coefficients are allowed, so the count need not be the degree of a polynomial plus one.
CONST Capacity = 1024;
TYPE Polynomial = RECORD
len: INTEGER;
coeff: ARRAY Capacity OF REAL
END;
PROCEDURE Horner(VAR p: Polynomial; x: REAL): REAL;
VAR i: INTEGER; value: REAL;
BEGIN
i := p.len; value := 0.0;
WHILE i > 0 DO
i := i-1;
value := p.coeff[i] + x*value
END;
RETURN value
END Horner;The representation invariant is , with only indices below
len significant. The parameter is passed by reference to avoid a full record copy; the procedure does not modify it.Let be the original coefficient count. At each guard test the loop invariant isThe empty sum is zero initially. If the old index is , after decrementing and updating,which preserves the loop invariant. The loop variant is , decreasing by one until zero. At exit,This is exactly the right-to-left nesting of Horner's method, matching the supplied right fold. It uses arithmetic operations and additional scalar storage.
REAL gives ordinary floating-point evaluation; the displayed identities specify the ideal arithmetic calculation, with the usual rounding in an actual floating-point implementation.Evaluate the mixed radix representation from its most significant end, using Horner's method. There is no need to compute the positional weights separately.The digit conditions are additional preconditions. The loop invariant at the loop test isAn empty sum is zero and an empty product is one, so initialization at is correct. For the next digit, writing giveswhich preserves the loop invariant. The loop variant is . At termination , givingThe code executes exactly multiplications, meeting the bound, and uses auxiliary space. When it returns zero. For the time representation in the source, it computes .
def digsToInt(xs: Array[Int], bs: Array[Int]): Int = {
require(xs.length == bs.length)
val N = xs.length
var i = N
var acc = 0
while (i > 0) {
i -= 1
acc = xs(i) + bs(i) * acc
}
acc
}Accumulate the prefix by Horner's method in base two. The loop invariant, in exact arithmetic, is that
digit-'0' converts either permitted digit to its numerical value:var i = 0
var integerPart = 0.0
while (i < bin.length && bin(i) != '.') {
integerPart = 2.0 * integerPart + (bin(i) - '0')
i += 1
}i is the number of processed digits before the point andAppending a digit shifts the old positional value by one binary place and adds that digit, which proves preservation. The loop variant is . At exit, i is the binary-point index or the length if no point occurs, and integerPart is the value of the integer prefix. An empty prefix contributes zero. There is one multiplication per processed digit, with no separate powers or repeated divisions. Short-circuit evaluation prevents an out-of-range access when the point is absent.For
Double, this exact-arithmetic invariant describes the intended value; the operational value is the rounded Horner recurrence. Very long prefixes can lose precision or overflow, as discussed in part (g). A fixed-width return type cannot represent every finite binary digit string exactly.Use Horner's method, accumulating the high-degree coefficients before the low-degree ones:
def eval(x: Double): Double = {
var i = a.length
var value = 0.0
while (i > 0) {
i -= 1
value = a(i) + x * value
}
value
}At each while loop head the loop invariant isThe initial sum is empty. Decreasing
i and replacing the accumulator by a(i) + x * value extends that sum by one coefficient with the required powers shifted. The loop variant is i; on exit it is zero, so the accumulator equals . The code uses exactly multiplications and time, with constant auxiliary space, and also handles the empty coefficient array as the zero polynomial. Initializing from the last coefficient instead would save one multiplication for nonempty arrays.The invariant is an exact-arithmetic specification. With
Double, each arithmetic operation rounds; consequently the code evaluates the Horner expression in floating-point arithmetic, rather than guaranteeing the exact real value for arbitrary coefficients. Polynomial Created 2026-09-24 Updated 2026-10-18
A polynomial is a finite sum of monomials with coefficients in a ring. In one variable over a commutative ring , writeThe symbol is an indeterminate: it records powers formally before we choose an input value. Finite expressions are easy to add, multiply, evaluate, and differentiate, making polynomials a common language for exact algebra and approximate numerical analysis.
Consider the real polynomialThe expanded form displays the coefficients and the degree of a polynomial; the factored form displays its roots of a polynomial. At , either description gives . At and , the factored form makes the zero values immediate. Keeping several descriptions of one object is useful because each makes a different question easy.
A simple polynomial root crosses the axis, while a double root touches it; perturbing the double factor can produce real or complex roots
. Details. The graph shows another connection. The factor changes sign across , while stays nonnegative across . Thus the graph crosses the axis at the simple root of a polynomial and touches it at the double root. Multiplicity of a root turns an algebraic repetition into visible local behavior.
For calculations, Horner's method evaluates a polynomial through nested multiplication. For modeling, a Taylor polynomial describes local behavior near a point, while polynomial interpolation constructs a polynomial matching prescribed data. Their usefulness comes with assumptions: a local approximation and an exact identity are different claims, and changing the coefficient ring can change which polynomial roots exist.

