Averaging down the triangle
Worth reading first: Every entry counts the routes to it · A bell curve assembled out of coin flips.
Pascal’s triangle is built by one rule: every entry is the sum of the two above it. Read as a grid of streets, that rule counts routes, and every identity between the entries becomes a statement about walking. Read modulo a prime, it becomes a question about digits.
Change the rule slightly. Instead of adding the two entries above, take a fixed share of each — of the one on the left and of the one on the right, for some between nought and one. The sum becomes an average, and the triangle becomes a machine for averaging.
Averaging down the triangle turns a polygon into a curve, and a function’s samples into a polynomial that approaches the function. Both are the same computation, and both inherit one property from the weights being shares: the result can never overshoot what it averages. That property is what makes the method safe, and it is also what makes it slow.
The rule with its parents weighted
The construction in the figure is due to Paul de Casteljau, who worked it out at Citroën in 1959. Start with a row of points. Replace each neighbouring pair by the point of the way from the first to the second. That gives a row one shorter; do it again, and again, until one point is left.
Every step is Pascal’s rule with weights. So the last point is some mixture of the control points, and the amount of each control point in it can be found the way the routes were counted. A route from the top of the triangle to control point takes steps, of them towards the right parent and towards the left; each right step multiplies the weight by and each left step by . There are such routes, each carrying , so
The count of routes is still there; each route has simply acquired a price. At with four control points the prices are , , and , the counts are 1, 3, 3 and 1, and the weights are 0.216, 0.432, 0.288 and 0.064. The figure computes them twice — once by pushing a weight of one down the weighted triangle, once from the formula — and requires the averaged point to equal the weighted sum.
The weights add to one, and the reason is the binomial theorem: they are the terms of , which is . The unweighted triangle’s rows add to for the same reason with in the brackets.
A row spread over the interval
Let run from nought to one and each weight becomes a polynomial. The polynomials are the Bernstein basis of degree , and they are row of the triangle laid out along an interval.
Three facts about the row are visible and each is checked. The polynomial for peaks at : setting its derivative to nought gives . Each encloses exactly , whatever is. And they add to one everywhere.
The second fact has a proof that uses no integration. Scatter points independently and uniformly on the interval, and colour one of them red. The integral is the chance that exactly of the other points land to the left of the red one: the red point sits at , and each of the others falls left of it with chance . But the points are exchangeable, so the red one is equally likely to be first, second, or any of the positions in order. Every has chance , so every curve encloses the same area. Thomas Bayes used the same argument, with a ball rolled on a table, in the essay published after his death in 1763.
So a row of the triangle is a partition of one into smooth pieces, each concentrated near its own point and each carrying the same total. That is exactly what is needed to average something that lives on the interval.
Why the curve cannot leave its polygon
The curve in the first figure is the set of points de Casteljau’s construction produces as runs from nought to one. Its formula is , and since the weights are never negative and always add to one, every point of the curve is a weighted average of the control points, and so lies inside their convex hull. The figure checks that for 121 points along the curve.
That is the property that made the curves useful. Pierre Bézier, independently at Renault in the early 1960s, used them to describe car bodies: a designer moves the control points, the curve follows without ever swinging outside the polygon they make, and the curve’s ends start at and finish at heading along the first and last sides. A point inside the hull of many points is inside the hull of a few, and a curve built from positive weights inherits the whole family of such statements.
Almost every curved outline on a screen is drawn this way. Letterforms in the TrueType format are pieces of quadratic curves, three control points each; those in PostScript fonts, and the C command in an SVG path, are cubic, with four. Rendering one is the construction in the figure run at many values of — a few multiplications and additions per round, no powers, no binomial coefficients, and no rounding error that can push a point outside the hull, because every intermediate point is itself an average.
Sampling a function instead of a polygon
Replace the control points by the values of a function at the evenly spaced points , and average them with the same weights:
This is the Bernstein polynomial of , and it has a reading that explains everything about it. The weights are the binomial distribution. Toss coins that each land heads with probability ; the chance of exactly heads is . So is the average value of at the proportion of heads — and the proportion of heads, for large , crowds around .
For the gap can be computed exactly. The average of the squared proportion is the square of its average plus its variance, and the variance of the proportion of heads in tosses is . So
and the figure checks that identity at all 241 of its points. The largest gap is at and is : 0.125 at degree 2, 0.031 at degree 8, 0.0078 at degree 32. The polynomial always lies above the curve, and the reason is general: for any function that bends upward, the average of its values exceeds its value at the average — the chord lies above the curve — and is an average of over a distribution whose mean is .
The same fact is why the method does not interpolate. A Bernstein polynomial agrees with its function only at the two ends; everywhere else it is a blur of nearby samples. That looks like a defect and is actually the source of the theorem below.
What the averages keep: order and bending
A blur loses detail, but this particular blur keeps two things exactly, and both come from the triangle.
Differentiate a Bernstein polynomial and the triangle’s previous row appears. The derivative of is
the differences between neighbouring samples, averaged with the weights of row . So if the samples rise from left to right, every difference is positive, every weight is positive, and the derivative is positive everywhere: a function that only increases has a Bernstein polynomial that only increases. The same computation one level further down averages the second differences with row , so a function whose samples bend upward has a polynomial that bends upward everywhere.
That is a property most ways of fitting a polynomial do not have. The polynomial through evenly spaced samples of an increasing function can wiggle down between them, and a least-squares fit can put a bump where the data has none. An averaging rule cannot invent a turning point, because at every it is a positive combination of the slopes the samples already have. For a designer that is the difference between a curve that follows the control polygon’s intentions and one that has ideas of its own; for a numerical analyst it is the reason Bernstein polynomials are used to prove that shape-preserving approximation is possible at all.
The derivative formula also says the derivatives converge. When has a continuous derivative, the differences divided by are samples of that derivative, and the same law-of-large-numbers argument applied to them shows that the slope of approaches the slope of uniformly. A single sequence of polynomials approximates the function and, at the same time, its slope.
Every continuous function, by tossing coins
In 1885 Karl Weierstrass proved that every continuous function on a closed interval can be approximated, uniformly, as closely as desired by a polynomial. In 1912 Sergei Bernstein gave a proof in half a page, and the polynomial it uses is .
The argument splits the average in two. Where the proportion of heads is close to , at the proportion is close to , because a continuous function on a closed interval changes by little over short distances — by at most some over any distance less than some , the same everywhere. Where the proportion is far from , can be anything up to its largest size, but Chebyshev’s inequality says the chance of being that far away is at most , which is at most whatever is. Make large enough and the second part is smaller than too.
Both bounds hold at every simultaneously, which is what makes the convergence uniform — the gap measured as the largest distance anywhere, not point by point. The proof is the law of large numbers, applied to a coin whose bias is the point being approximated.
The proof asks for continuity and nothing more, and a function with a corner shows what that minimum buys. At the polynomial is the average distance of the proportion of heads from one half, and the proportion’s spread is . The average distance from the centre of a bell curve is its spread times , so the gap is about — to halve it takes four times the degree. The figure’s third column is the gap times , and it settles at exactly that constant.
Smoothness buys nothing past one over n
A corner costs a square root. The natural expectation is that a smooth function does much better — that for a function with every derivative, the gap should fall faster and faster, as it does for a Taylor series inside its radius.
It does not. The gap times the degree settles to a constant instead of falling, so the gap itself shrinks only like , the same rate as for . For every function with a second derivative, times the gap tends to — Elizaveta Voronovskaya’s theorem of 1932 — and that limit is nought only where the function is straight. The converse is also known: a Bernstein polynomial whose largest gap falls faster than belongs to a straight line. Infinitely many derivatives do not help, because the method never uses any of them.
The reason is the blur. averages over a spread of width about around ; averaging a curved function over a spread of that width misses its value by its curvature times the square of the width, which is . The positive weights that keep the curve inside its polygon are the same weights that smear the function, and a smear of positive weights cannot cancel curvature — cancelling would need some weights to be negative.
The rate, measured
On logarithmic scales a rate of is a line of slope and a rate of a line of slope , and the figure’s lines are those. lies exactly on its line from the first degree. The sine joins it after a few doublings. The corner runs parallel at half the slope.
The fourth line is the function that defeats interpolation at evenly spaced points. There, the polynomial through 41 equally spaced samples of it missed by more than six. Here the error at degree 512 is 0.043 and falling. Bernstein polynomials never diverge — every one of them lies between the function’s smallest and largest sample values — but for Runge’s function they are still far from their eventual slope of at degree 512, because its curvature at the centre is large and the constant in front of is correspondingly big.
That is the trade in one figure. Interpolation at the right points converges geometrically for a function like this, adding a fixed number of correct digits per doubling. Bernstein’s averaging converges for every continuous function without exception and never overshoots, and it pays for that with a rate that is never better than . A method that cannot go wrong has given up the means of going fast.
Where the construction needs its hypotheses
The function has to be continuous on a closed interval. Bernstein’s proof uses the fact that a single works everywhere, which fails on an open interval — near nought has no such — and fails for a function with a jump, where the polynomials converge to the midpoint of the jump rather than to either side.
The samples are at evenly spaced points, and they must be. The binomial distribution with mean is what makes the average centre on ; move the samples and the weights no longer average towards the right place.
The weights must be positive. Every good property here — the hull, the absence of overshoot, convergence for every continuous function — comes from the weights being shares. Every limitation — the floor, the failure to interpolate — comes from the same place.
And a Bernstein curve is a polynomial. No polynomial curve traces an exact circle, so a circle drawn from control points needs a further step: weights attached to the control points themselves, which makes the curve a ratio of two polynomials.
The rate is measured to degree 512 and proved beyond it
The largest gap in every figure is found on a grid of 1,001 points. For and for the corner the largest gap sits at , which is on the grid, so the values are exact; for the sine and Runge’s function it sits between grid points, and the value shown is a lower bound that is accurate to within the grid spacing times the slope there.
The rate figure stops at degree 512. The slopes over the last three doublings are measurements, and a measured slope of −0.81 for Runge’s function is a statement about degrees 128 to 512, not about the limit; that the limit is −1 is Voronovskaya’s theorem and not something the figure shows.
And the first figure shows the construction at one value of . The curve is drawn from 121 values, each computed by the same rounds of averaging, but only one set of rounds is drawn — the picture of all of them would be a triangle of triangles, and no single one of its lines would be readable.
Still open: the best a polynomial can do at a corner
Bernstein’s own polynomials approach like . They are far from the best polynomials of the same degree, which are not averages and are allowed negative weights in effect. Bernstein himself studied that best approximation: for on the interval from to , the smallest possible largest gap for a polynomial of degree behaves like for a constant near 0.2802.
He conjectured in 1914 that is , a guess that agreed with his numerical evidence to two figures. Richard Varga and Amos Carpenter showed in 1985, by computing the best approximations to high degree with great precision, that it is not: . No closed form for it is known, nor any proof that it is related to any other constant. So the rate at which the best possible polynomials approach the simplest possible corner is a number known to many digits and to no formula.
Safety and speed are bought with the same weights
The habit worth keeping is about properties that come as a pair.
Weighted averaging down the triangle has a property that is easy to admire: whatever it is given, its output stays within the range of its input — inside the hull of a polygon, between the smallest and largest sample of a function. That is why designers could trust the curves and why Bernstein’s proof works for every continuous function. It is tempting to treat that property as a free benefit and the slow rate as a separate flaw. It is not separate. A rule that can never overshoot has to average, an average over a spread cannot recover curvature, and so the floor is the price of the guarantee rather than a defect alongside it.
When a method has a strong guarantee and a disappointing rate, look for the single choice responsible for both. Here it is the positivity of the weights, and every faster method of approximation — interpolation at well-chosen points, the best approximation Bernstein studied — gets its speed by giving the guarantee up.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- A dimension for every rate of crowding — both name binomial coefficient, law of large numbers
- A polynomial through the gaps — both name interpolation, polynomial
- Counting the paths that go wrong — both name binomial coefficient, lattice paths
Named objects
A dashed tag is an object no other essay names yet.
ApproximationBinomial coefficientBinomial distributionConvex hullInterpolationLattice pathsLaw of large numbersPolynomialUniform convergence