Beyond the five points

Lagrange's mathematics

Three of his results that are easy to state and pleasant to play with.

Interpolation

Given n points with different x-coordinates, there is exactly one polynomial of degree at most n−1 that passes through all of them. Lagrange's formula writes it down directly, as a sum of one simple polynomial per point, each of which is 1 at its own point and 0 at all the others. Drag the points; switch on the basis polynomials to see the pieces.

degree 4

Add a few points and the curve starts to swing wildly between them near the edges: the Runge phenomenon, and the reason high-degree interpolation is used with care.

Four squares

In 1770 Lagrange proved that every natural number can be written as the sum of four perfect squares (zero allowed). Bachet had conjectured it in 1621, and Fermat claimed a proof he never published. Type a number to find one way of doing it.

Three squares are not always enough: 7 needs four, and so does any number of the form 4a(8b + 7).

Multipliers

To find the largest value of a function f along a constraint g = c, look for places where the level curves of f just touch the constraint curve. There the two gradients are parallel, ∇f = λ∇g, and the extra unknown λ is the Lagrange multiplier. Lagrange introduced the idea in the Mécanique analytique to handle constraints on mechanical systems.

xy=4xy=6 (2, 2) x + y = 4 ∇f ∥ ∇g
Maximising xy on the line x + y = 4. The level curve xy = 4 touches the line at (2, 2), where the gradients of both functions point the same way.