← Home · Mechanics and everyday physics · Lagrangian mechanics · Hamiltonian mechanics · 🇩🇰 Dansk

Least time and least action – the calculus of variations

Light finds the fastest way through glass and water. A bead that must slide as quickly as possible from A to B does not choose the straight line but a cycloid – a problem Isaac Newton solved in a single night after a day's work at the Royal Mint. And according to Richard Feynman, an electron in fact tries every path at once. This page follows the thread from Fermat through Bernoulli, Euler and Lagrange to Feynman – with four interactive simulations.

Fermat and the refraction of light

Around AD 60 Heron of Alexandria showed that light reflected in a flat mirror follows the shortest path from the eye via the mirror to the object. This gives the law that the angle of incidence equals the angle of reflection. But in refraction – when light passes from air into water – the shortest path is the straight line, and light does not follow it. The law of refraction was discovered several times: by Ibn Sahl in Baghdad in 984, by Willebrord Snell in Leiden around 1621, and by René Descartes, who published it in 1637:

$$n_1\sin\theta_1=n_2\sin\theta_2 .$$

Descartes' explanation required light to travel faster in water than in air. Pierre de Fermat was not convinced. In a letter of 1662 he started from the opposite assumption: light is slower in denser substances, and it chooses the path that takes the least time. With speed $v_1$ in air, $v_2$ in water and the interface struck at the point $x$, the time is

$$T(x)=\frac{\sqrt{a^2+x^2}}{v_1}+\frac{\sqrt{b^2+(d-x)^2}}{v_2},\qquad \frac{\mathrm dT}{\mathrm dx}=\frac{x}{v_1\sqrt{a^2+x^2}}-\frac{d-x}{v_2\sqrt{b^2+(d-x)^2}}=0 \;\;\Longrightarrow\;\;\frac{\sin\theta_1}{v_1}=\frac{\sin\theta_2}{v_2}.$$

This is Snell's law with $n=c/v$. Fermat obtained the correct law from the opposite assumption about the speed of light, and only in 1850 did Léon Foucault settle the dispute: light goes more slowly in water. Every lifeguard knows the same calculation. You run faster on the sand than you swim, so you run some way along the beach before jumping into the water – exactly so far that $\sin\theta_1/v_1=\sin\theta_2/v_2$.

Drag A, B or the point on the interface
Try it yourself. The graph at the bottom right shows the time $T$ for every possible point on the interface.
  1. Drag the point around and find the least time. Do $n_1\sin\theta_1$ and $n_2\sin\theta_2$ (shown in the readout) then agree?
  2. Press "Race". Two flashes of light leave A at the same moment – along your path and along the fastest. By how much does the fastest win?
  3. Notice how flat the graph is near the minimum. A small error in the angle costs almost no time. That matters in Feynman's explanation.
  4. Choose the lifeguard. How far should she run along the beach before jumping in?

Mirages and Bernoulli's layers

When the speed changes gradually, the light ray becomes curved. Above a sun-baked road the air is densest higher up and thinnest just above the asphalt, so light goes fastest at the bottom and bends upwards: you see the sky reflected in the road like a puddle. Johann Bernoulli saw that the same principle could solve a quite different problem. Imagine light in a medium of many horizontal layers, in which the speed at depth $y$ is $v=\sqrt{2gy}$ – the speed a ball has after falling the distance $y$. At every interface Snell's law holds, so all the way down

$$\frac{\sin\theta}{v}=\text{constant}.$$

The light ray that travels fastest from A to B is therefore also the path along which a ball slides fastest. Switch to "Many layers" and turn up the number: the broken ray approaches the dashed curve – a cycloid.

The brachistochrone – the problem of quickest descent

In June 1696 the Swiss mathematician Johann Bernoulli posed in the journal Acta Eruditorum a "new problem which mathematicians are invited to solve":

Given two points A and B in a vertical plane, find the path AMB along which a moving body M, descending under its own weight alone, passes from A to B in the shortest time.

The word brachistochrone is Greek for "shortest time". The straight line is the shortest path, but not the fastest: a steeper start gives great speed early on, which can then be used for the rest of the way. Galileo Galilei had shown in his Discorsi of 1638 that a circular arc is faster than the straight line, and conjectured that the circular arc was the fastest of all. He was wrong. Bernoulli first gave the mathematicians six months, but on Leibniz's advice he extended the deadline to Easter 1697 with a printed notice dated 1 January 1697. It was addressed to "the most acute mathematicians flourishing throughout the world" – and it was no secret that he had one in London particularly in mind.

Newton's evening – 29 January 1697

Newton was then 54 and had left Cambridge to become Warden of the Royal Mint in London, where he was directing the Great Recoinage of England's silver coins. On 29 January 1697 he came home from the Mint at 4 p.m. and found Bernoulli's notice. According to his niece, Catherine Conduitt, who lived with him, he did not go to bed until he had solved it – at 4 o'clock in the morning. The next day he sent the solution to the President of the Royal Society, Charles Montague, and it was printed without his name in the Philosophical Transactions for January 1697: the curve is a cycloid, and it can be constructed thus and thus. Newton gave no derivation.

In May 1697 the Acta Eruditorum printed the solutions. Five had replied: Newton, Johann's elder brother Jakob, Leibniz, Guillaume de l'Hôpital and Ehrenfried Walther von Tschirnhaus. Johann wrote in a letter that spring that he had at once recognised the author, ex ungue leonem – "as the lion is known by its claw". (The historian D. T. Whiteside has pointed out that Bernoulli probably meant only that he could identify the author, not that he bowed to him.) Johann himself had taken two weeks. John Wallis and David Gregory tried for three months without success.

Johann's solution: light shows the way

Johann used Fermat and Snell as above. Let $\theta$ be the angle between the path and the vertical. With $\sin\theta = 1/\sqrt{1+y'^2}$ and $v=\sqrt{2gy}$, $\sin\theta/v=$ constant gives

$$y\,(1+y'^2)=2R ,$$

where $R$ is a constant. This differential equation has the solution

$$x=R(\varphi-\sin\varphi),\qquad y=R(1-\cos\varphi),$$

the curve traced by a point on the rim of a wheel of radius $R$ as the wheel rolls beneath a horizontal line. Johann was delighted: the light ray and the falling ball obey the same law.

Jakob's solution: the first calculus of variations

Jakob Bernoulli took another route. If the whole curve is the fastest, then every small piece of it must also be the fastest between its end points. He therefore varied the curve slightly over a small region and required that the time should not change to first order. The method was laborious, but it could be applied to many other problems, and it became the germ of the calculus of variations. It also sparked a bitter feud between the two brothers that was never settled.

The race in 3D

Five beads slide without friction down their own wires from A to B: a straight line, Galileo's circular arc, a parabola, the cycloid and a curve that dips deeper than the cycloid. All start at rest at the same height and finish at the same place. The times are calculated from conservation of energy, $v=\sqrt{2gy}$. Try changing the ratio between B's distance and depth.

Drag: rotate · pinch/scroll: zoom
Try it yourself.
  1. Who wins, and by how much? Is Galileo's circular arc faster than the straight line?
  2. Make B's distance large compared with its depth (over $\pi/2\approx1.57$). Now the cycloid dips below B and runs uphill at the end. Why does that pay?
  3. The deep curve reaches the greatest speed. Why does it lose anyway?

The tautochrone – Huygens' pendulum clock

As early as 1673 Christiaan Huygens had shown in Horologium oscillatorium that the cycloid has another remarkable property. A ball released from rest anywhere on an inverted cycloid reaches the bottom after exactly the same time,

$$t=\pi\sqrt{R/g},$$

however high up it started. The reason is that the height above the bottom is proportional to the square of the arc length $s$ to the bottom: $h=s^2/(8R)$. The component of gravity along the path is therefore proportional to $s$, and the motion is a harmonic oscillation – exactly isochronous. An ordinary pendulum swings in a circular arc and is isochronous only for small swings. Huygens built a pendulum clock in which the string hung between two cycloid-shaped "cheeks", so that the bob was forced to follow a cycloid. Johann Bernoulli ended his solution in astonishment: "This same curve, Huygens' tautochrone, is the brachistochrone we were seeking."

The calculus of variations

The brachistochrone is a new kind of problem. You must find not a number that makes a function smallest, but a whole function $y(x)$ that makes an integral smallest:

$$T[y]=\int_A^B\frac{\mathrm ds}{v}=\int_0^{x_B}\frac{\sqrt{1+y'^2}}{\sqrt{2g\,y}}\,\mathrm dx .$$

Such a "function of a function" is called a functional. In 1744 Leonhard Euler gathered all the known problems in his book Methodus inveniendi lineas curvas maximi minimive proprietate gaudentes – "A method for finding curved lines enjoying properties of maximum or minimum". In 1755 the 19-year-old Lagrange sent him a far simpler method, and Euler named the subject the calculus of variations. For a functional $J[y]=\int F(x,y,y')\,\mathrm dx$ with fixed end points, the condition is that $y$ satisfies the Euler–Lagrange equation

$$\frac{\mathrm d}{\mathrm dx}\frac{\partial F}{\partial y'}-\frac{\partial F}{\partial y}=0 .$$

The derivation is on the page on Lagrangian mechanics. If $F$ does not depend on $x$ directly, the equation has a first integral, the Beltrami identity:

$$F-y'\frac{\partial F}{\partial y'}=C .$$

For the brachistochrone $F=\sqrt{1+y'^2}/\sqrt{y}$ (the constant $\sqrt{2g}$ does not matter). Then $F-y'F_{y'}=1/\big(\sqrt y\sqrt{1+y'^2}\big)=C$, so $y(1+y'^2)=1/C^2=2R$ – exactly Johann's equation, now without light.

ProblemFunctional to be minimisedSolution
Shortest path in the plane$\int\sqrt{1+y'^2}\,\mathrm dx$Straight line
Fermat: the path of light$\int n(x,y)\,\mathrm ds$Snell's law, curved rays, mirages
The brachistochrone (1696)$\int \mathrm ds/\sqrt{2gy}$Cycloid
The catenary (Jakob Bernoulli 1690)Height of the centre of gravity $\int y\,\mathrm ds$ at fixed length$y=a\cosh(x/a)$ – solved by Johann, Leibniz and Huygens in 1691
Dido's problemGreatest area for a given perimeterCircle
Soap film between two ringsArea $2\pi\int y\sqrt{1+y'^2}\,\mathrm dx$Catenoid (Euler 1744)
Geodesics on the EarthLength on the sphereGreat circles – the air routes over Greenland
Mechanics (Hamilton 1834)The action $\int (T-V)\,\mathrm dt$Newton's motions

Dido's problem is named after the legend of Queen Dido, who founded Carthage: she was allowed as much land as an oxhide could enclose, cut the hide into a thin strip and laid it in an arc against the coast.

Find the fastest path yourself

Here you can draw your own path. Drag the curve and watch the bead's time change. Then press "Let nature choose": the program changes the curve step by step in the direction that lowers the time most (the gradient method) – a numerical version of Jakob Bernoulli's idea – and ends up on the cycloid.

Drag the curve

From least time to least action

In 1744 – the same year as Euler's book – Pierre-Louis Moreau de Maupertuis, who two years later became President of the Berlin Academy, proposed that both light and bodies follow a path on which a quantity he called the action is least. To him it was proof of the Creator's economy: nature never spends more than it needs. The formulation was vague, and it became the subject of one of the great scandals of the Enlightenment. Samuel König claimed in 1751 that Leibniz had found the principle first, and Voltaire mocked Maupertuis in the satire Docteur Akakia (1752). But Euler gave the principle a precise form for a body in a field of force, and Lagrange and Hamilton made it the foundation of all mechanics: of all conceivable paths with fixed end points in space and time, a body follows the one that makes

$$S=\int_{t_1}^{t_2}\big(T-V\big)\,\mathrm dt$$

stationary. You can try it yourself for a thrown ball on the page on Lagrangian mechanics, and see how the principle leads to phase space on the page on Hamiltonian mechanics.

The principle raises a philosophical question that has troubled physicists for three hundred years. Newton's law is local: the force here and now determines the acceleration here and now. The principle of least time or action is global: it compares whole paths, and it looks as if the light or the ball "knows" in advance where it is going and chooses the best way. How can light know which path is fastest before it has tried them? Feynman's answer: it tries them all.

Feynman: the sum over all paths

"When I was in high school, my physics teacher – whose name was Mr. Bader – called me down one day after physics class and said, 'You look bored; I want to tell you something interesting.' Then he told me something which I found absolutely fascinating, and have, since then, always found fascinating. Every time the subject comes up, I work on it."

So begins Richard Feynman's lecture on the principle of least action in The Feynman Lectures on Physics, volume II, chapter 19. Abram Bader of Far Rockaway High School in New York had shown the young Feynman the principle, and it never let him go. As a PhD student at Princeton under John Wheeler he wanted to formulate quantum mechanics from the action rather than the Hamiltonian. In his Nobel lecture he told how in 1941, at a beer party in the Nassau Tavern, he asked the newly arrived German physicist Herbert Jehle whether he knew of a way of using the action in quantum mechanics. Jehle pointed him to a short paper by Paul Dirac from 1933, The Lagrangian in Quantum Mechanics. Dirac had written that the transition from one moment to the next "corresponds to" $e^{iS/\hbar}$. The next day Feynman worked it through on the blackboard with Jehle and found that it was not merely an analogy – it was proportional, and with the right constant it was equal.

The result became Feynman's thesis (1942) and the paper Space-Time Approach to Non-Relativistic Quantum Mechanics in Reviews of Modern Physics (1948). The quantum-mechanical probability amplitude for going from A to B is a sum over all conceivable paths, each with its own phase:

$$K(B,A)=\sum_{\text{all paths}}e^{\,iS[\text{path}]/\hbar},\qquad P(A\to B)=|K|^2 .$$

Each path contributes a little arrow of the same length, turned through the angle $S/\hbar$. For a ball, $S$ is millions of times larger than Planck's constant $\hbar=1.05\times10^{-34}$ J·s, so even a small change in the path turns the arrow round many times, and the contributions from neighbouring paths cancel. Only near the path where $S$ is stationary – where a small change in the path does not change $S$ to first order – do the arrows point the same way and add up. That is why balls and planets follow the classical path, and why the principle is about "least" or rather "stationary". For an electron in an atom, by contrast, $S$ is only a few $\hbar$, and many different paths contribute: that is quantum interference. Classical mechanics is thus the limiting case $\hbar\to0$ of quantum mechanics, just as ray optics is the limiting case of wave optics for very short wavelengths.

Feynman's mirror

In the book QED – The Strange Theory of Light and Matter (1985), based on four popular lectures, Feynman explains it all with a mirror and a stopwatch. A photon can go from the source S to the detector P via any point on the mirror. Imagine a stopwatch whose hand turns round while the photon is on its way: when the photon arrives, the hand points in a certain direction, and that is the path's arrow. Lay all the arrows head to tail: the total arrow from start to finish determines how likely it is that light reaches P. Try it yourself:

Try it yourself. The middle graph shows the time for each path. The arrows on the right are laid head to tail in the same order as the strips of the mirror.
  1. Place the detector so that the angle of incidence equals the angle of reflection (2.6 with the fixed source). Which strips give most of the total arrow? Why are they the ones where the time curve is flat?
  2. Choose "Edges only". Now the mirror is almost gone – and almost no light arrives. Choose "Middle only": why is that enough?
  3. Move the detector away from the mirror angle and press "Scrape a grating". The program removes the strips whose arrows point "the wrong way". Now the mirror reflects at a slant. Change the wavelength: the grating works for one colour only – that is why a CD shines in the colours of the rainbow.
  4. Make the wavelength small. What happens to the part of the mirror that contributes? That is the limit of ray optics and of Fermat's principle.

Feynman's mirror shows why Fermat's principle works. Light does not "choose" the fastest path; it goes every way. But only near the fastest path is the time almost the same for neighbouring paths, so only there do the arrows add up. That is also why a mirror need not be perfect far out to the side, and why light can be made to go "wrong" ways with a grating. The brachistochrone's cycloid, Snell's law and Newton's laws of motion are all three the same principle seen in the limit where the wavelength – or Planck's constant – is small.

Exercises

  1. Show that Heron's principle (shortest path via a mirror) gives angle of incidence = angle of reflection. (Hint: reflect B in the mirror.)
  2. A lifeguard stands 20 m from the water's edge and sees a swimmer 30 m out and 50 m further along the coast. She runs at 7 m/s and swims at 1.5 m/s. Write down $T(x)$ and find the best place to enter the water numerically.
  3. Show that the cycloid $x=R(\varphi-\sin\varphi)$, $y=R(1-\cos\varphi)$ satisfies $y(1+y'^2)=2R$. (Hint: $y'=\dfrac{\mathrm dy/\mathrm d\varphi}{\mathrm dx/\mathrm d\varphi}$.)
  4. Show that the time from A down the cycloid to the parameter value $\varphi$ is $t=\varphi\sqrt{R/g}$. How long does it take to reach the bottom with $R=1$ m?
  5. Use the Beltrami identity on $F=y\sqrt{1+y'^2}$ and show that the solution is a catenary $y=a\cosh\big((x-x_0)/a\big)$.
  6. For a 50 g ball thrown 10 m up, the action is of the order of 5 J·s. How many times $\hbar$ is that? Why do we never see the ball "trying" other paths?

Sources and further reading

Related pages: Mach's mechanics · Lagrangian mechanics · Hamiltonian mechanics · Newton's Principia · Quaternions.