Solution (source code)

= Solution

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 $O(p^2)$ 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 $O(p)$ 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 $[0,1]$ 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 $O(\log n)$ for sorted arbitrary knots, constant work for a uniform interior span, or amortized constant work for an ordered sequence of sample parameters. \b[Use de Boor for robust general knots, shared basis weights for batches, and precomputed local polynomials or Bézier pieces for repeated interrogation.]