the calculus of variations
Ordinary calculus finds the number that minimizes a function. The calculus of variations does something grander: it finds the whole function -- the shape of a curve, the path of a particle -- that minimizes (or extremizes) a quantity. What curve does a hanging chain make? Along what path does light travel? What trajectory does nature actually pick? These are its questions.
The quantity to be extremized is a functional -- a number assigned to a whole function -- typically an integral S[y] = the integral from a to b of L(x, y, y') dx. Demanding that S be stationary (unchanged to first order) under any small variation y -> y + delta y that fixes the endpoints leads to the Euler-Lagrange equation: d/dx (partial L / partial y') - (partial L / partial y) = 0. Any function satisfying it makes the functional stationary; this converts an infinite-dimensional search over functions into a differential equation to solve.
This is the mathematical backbone of theoretical physics. Set L to the Lagrangian (kinetic minus potential energy) and the Euler-Lagrange equation is Newton's second law -- the principle of least action. The same machinery gives the geodesic equation in general relativity (extremal spacetime paths), Fermat's principle in optics (least time), and, through Noether's theorem, ties every continuous symmetry of the action to a conservation law. Constraints are handled by Lagrange multipliers within the same framework.
The shortest path between two points: minimize the length integral of sqrt(1 + y'^2) dx. Here L does not depend on y, so partial L/partial y = 0 and Euler-Lagrange gives partial L/partial y' = constant, forcing y' = constant -- a straight line, as it must be.
Extremizing arc length yields the straight line.
Stationary does not mean minimum: the Euler-Lagrange equation only makes the functional stationary. A path can be a saddle of the action, and in optics light can take a path of maximum or stationary time, not strictly least -- 'least action' is a historical misnomer for 'stationary action'.