What you select
A square contributes its center, (xᵢ, yᵢ). If its zero-based column is tᵢ and there are s columns per quarter-note beat, xᵢ = tᵢ/s. The bottom lane has y = 1. Coordinates refer to the as-punched strip. On the inverted view, a clicked lane y corresponds to source lane L + 1 − y. Selecting a point does not punch a hole.
What “fit” means
For n ≥ 1 points with distinct x coordinates, there is exactly one polynomial p of degree at most n − 1 satisfying p(xᵢ) = yᵢ for every selected point. One point gives a constant. Collinear points give a line or a constant, even when n is larger. No points means no fit. The app permits one point per column, up to every column on the strip.
Different heights at the same x are inconsistent: a function cannot take two values there. Remove the old point before selecting another in its column. This is interpolation: every constraint is met, with no least-squares approximation or smoothing.
The formula
An empty product equals 1. At xᵢ, ℓᵢ equals 1; at every other selected xⱼ it equals 0. Thus p(xᵢ) = yᵢ. Each term has degree at most n − 1. This proves existence.
If two polynomials of degree at most n − 1 fit the points, their difference has n distinct roots. A nonzero polynomial of degree at most n − 1 cannot do that. Their difference is zero. This proves uniqueness.
The degree bound matters. Without it, every polynomial p(x) + q(x) ∏ᵢ(x − xᵢ) also fits, for any polynomial q. The app chooses the unique polynomial within the stated bound.
The interpolation formula and degree bound are given in NIST DLMF §3.3.
What the computer evaluates
The app uses the equivalent Newton form in column coordinates t = sx. Start with Dᵢ,₀ = yᵢ. Then Dᵢ,ₖ = (Dᵢ₊₁,ₖ₋₁ − Dᵢ,ₖ₋₁)/(tᵢ₊ₖ − tᵢ). Set cₖ = D₀,ₖ. The resulting polynomial is p(x) = c₀ + c₁(sx − t₀) + c₂(sx − t₀)(sx − t₁) + ⋯.
Column indices and lane numbers are integers. Divided differences are stored as exact fractions with arbitrary-size integer numerators and denominators. Evaluation also uses exact fractions at each represented sample x; only the final y is converted to floating point for drawing. The save code stores the selected points, so loading reconstructs the same polynomial.
What gets punched
The blue rings are selected centers. Gold squares meet the displayed curve. “Fit polynomial” draws; “Punch crossed squares” adds holes. The x range applies to both functions and polynomials. Beyond the leftmost or rightmost selected point, the polynomial is extrapolating.
The displayed curve is a polyline, sampled at least 32 intervals per grid column and refined at midpoints when their deviation exceeds 0.015 lane. Selected x coordinates inside the plotting range are included as samples. Intervals whose endpoints and midpoint all lie beyond the same edge are omitted. Refinement has finite limits; unresolved intervals are omitted. Selected centers remain represented even where an adjacent interval is unresolved. This is a numerical picture, not a proof that every crossing of the exact polynomial has been found. High-degree interpolation can oscillate severely, even between points. More points need not make a calmer curve.
For column t and lane y, its closed square spans (t − ½)/s ≤ x ≤ (t + ½)/s and y − ½ ≤ f ≤ y + ½. A shared boundary belongs to both squares. The intersection calculation uses a 10⁻⁹ tolerance in grid coordinates to absorb floating-point error. The plotted stroke’s thickness does not count.
On the second Möbius pass, the graph becomes L + 1 − p(x). Its time coordinate is unchanged. The same physical holes are heard in reflected lanes.