A hanging chain

I remember reading Feynman II back in my youth and being blown away by the calculus of variations chapter, and immediately trying to play with it in every single different context I could. This is one of them, slightly more complex than those in the gospel according to RPF. We’re going to go on a route around the world and end up in a perhaps unexpected place.

Suppose you’ve got a chain hanging under gravity. What shape does it take? Let’s parametrize the shape as (π‘₯(𝑠),𝑦(𝑠)) where 𝑠 is arc length. Then its potential energy is

∫0πΏπœŒπ‘”π‘¦(𝑠)d𝑠

where 𝐿 is total length, 𝜌 is mass-per-unit-length and 𝑔 is, of course, gravity. When the chain is in steady state this will be at a minimum.

But, I hear you say, this clearly has no minimum because 𝑦 can be made arbitrarily negative. There is a trick β€” remember I said that 𝑠 is arc length. We need to include that constraint in our minimization; what we actually minimize is

β„’οΈ€=∫0πΏπœŒπ‘”π‘¦(𝑠)+πœ†(𝑠)2((dπ‘₯d𝑠)2+(d𝑦d𝑠)2βˆ’1)d𝑠

where πœ†(𝑠) is a Lagrange multiplier to enforce the arc length constraint1. It’ll actually turn out to be the tension in the chain.

Now the calculus of variations trick. What we’re going to do is to say that β„’οΈ€ is stationary with respect to first-order variations in π‘₯(𝑠), 𝑦(𝑠), and πœ†(𝑠). This is exactly the same β€œstationary to first order” trick that works for minimization of functions, here played on this integral. Let’s set π‘₯(𝑠)↦π‘₯(𝑠)+𝛿π‘₯(𝑠), 𝑦(𝑠)↦𝑦(𝑠)+𝛿𝑦(𝑠), and πœ†(𝑠)β†’πœ†(𝑠)+π›Ώπœ†(𝑠) and catch the first order terms. We get

𝛿ℒ︀=∫0πΏπœŒπ‘”π›Ώπ‘¦(𝑠)+π›Ώπœ†(𝑠)2((dπ‘₯d𝑠)2+(d𝑦d𝑠)2βˆ’1)+πœ†(𝑠)(dπ‘₯d𝑠d𝛿π‘₯d𝑠+d𝑦d𝑠d𝛿𝑦d𝑠)d𝑠,

and a bit of staring reveals that we’ve got d𝛿π‘₯d𝑠 and d𝛿𝑦d𝑠 terms that we don’t know what to do with. So we need to get rid of them. Fortunately we remember that we can integrate by parts to get

𝛿ℒ︀=∫0𝐿(πœŒπ‘”βˆ’dd𝑠(πœ†(𝑠)d𝑦d𝑠))𝛿𝑦(𝑠)βˆ’(dd𝑠(πœ†(𝑠)dπ‘₯d𝑠))𝛿π‘₯(𝑠)+((dπ‘₯d𝑠)2+(d𝑦d𝑠)2βˆ’1)π›Ώπœ†(𝑠)2d𝑠.

The endpoint terms go away because we require 𝛿π‘₯(0)=𝛿𝑦(0)=𝛿π‘₯(𝐿)=𝛿𝑦(𝐿)=0 β€” the chain is fixed at its start and end and our variations 𝛿π‘₯ and 𝛿𝑦 must respect that.

Differential equations for fun and profit

Our variational terms are otherwise arbitrary, so if we want first-order variations to be zero (i.e. stationary energy) we get

dd𝑠(πœ†(𝑠)d𝑦d𝑠)=πœŒπ‘”,dd𝑠(πœ†(𝑠)dπ‘₯d𝑠)=0,(dπ‘₯d𝑠)2+(d𝑦d𝑠)2=1.

We’ll impose the conditions 𝑦(0)=𝑦(𝐿)=0, π‘₯(0)=βˆ’π‘Ž, π‘₯(𝐿)=π‘Ž, so that our string hangs between (βˆ’π‘Ž,0) and (π‘Ž,0). Integrating the first two equations we get

πœ†(𝑠)dπ‘₯d𝑠=πœŒπ‘”π‘,πœ†(𝑠)d𝑦d𝑠=πœŒπ‘”(π‘ βˆ’π‘ βˆ—).

in which 𝑝 and π‘ βˆ— are constants of integration2. Now we substitute into the arc length constraint to get

πœ†(𝑠)2=𝜌2𝑔2(𝑝2+(π‘ βˆ’π‘ βˆ—)2)

and therefore3

d𝑦d𝑠=π‘ βˆ’π‘ βˆ—π‘2+(π‘ βˆ’π‘ βˆ—)2,

giving

𝑦(𝑠)=π‘ž+𝑝2+(π‘ βˆ’π‘ βˆ—)2.

We are almost home and dry:

dπ‘₯d𝑠=11+π‘βˆ’2(π‘ βˆ’π‘ βˆ—)2.

Make the change of variable 𝑠=π‘ βˆ—+𝑝sinhπœƒ to get π‘₯=𝑝(πœƒβˆ’πœƒ0), which we rewrite as

𝑦=π‘ž+𝑝cosh(π‘₯𝑝+πœƒ0).

Continuing on our merry way we find πœƒ0=0 and

𝑦=𝑝(coshπ‘₯π‘βˆ’coshπ‘Žπ‘).

We get 𝑝 by solving 𝐿=2𝑝sinhπ‘Žπ‘; the simplest way to do this is to let 𝑝=π‘Žπœ‰ and solve 𝐿2π‘Ž=sinhπœ‰πœ‰. Reassuringly, we see there is no solution if 𝐿<2π‘Ž. A perhaps slightly surprising result is that the shape does not depend on 𝜌 or 𝑔 β€” all heavy chains hang the same way. (This is in fact not surprising: by redefining πœ†(𝑠) we can factor πœŒπ‘” out of our Lagrangian.)

(Some years ago those nice guys Vella, Metcalfe, and Whittaker did something very much like this for floating rafts.)

Where this goes

Honestly, lots of places. One route ends up in Serious Numerical Analysis β€” the finite element methods that are the standard PDE solvers for solid mechanics and the Sobolev spaces that are the mathematical theory thereof4. Another route ends up in the very beautiful Lagrangian and Hamiltonian formulations of physics.

And one trivial and irrelevant byway that second route goes down is symplectic geometry, where you learn that the iteration

𝑝𝑛+12=π‘π‘›βˆ’πœ•π‘ˆπœ•π‘ž|π‘žπ‘›Ξ”π‘‘2π‘žπ‘›+1=π‘žπ‘›+𝑝𝑛+12Δ𝑑𝑝𝑛+1=𝑝𝑛+12βˆ’πœ•π‘ˆπœ•π‘ž|π‘žπ‘›+1Δ𝑑2

exactly preserves the 2-form dπ‘π‘›βˆ§dπ‘žπ‘›. And that is the reason that Hamiltonian Monte Carlo methods are so effective, linking us neatly back to my usual beat5. Maths… gotta know it all.

  1. 1If I was a real man I would use πœ†(𝑠)((dπ‘₯d𝑠)2+(d𝑦d𝑠)2βˆ’1), but we will in fact get the same differential equations back from our version.
  2. 2I have been cunning and scaled the constants appropriately because I know how this is going to go.
  3. 3There is a choice of sign here: our optimization has two solutions β€” a maximum in which the chain goes up and a minimum in which the chain goes down. We want the minimum and have chosen the positive square root, and, slight subtlety, this means that 𝑝>0.
  4. 4If you try solving our problem this way, note that our Lagrangian integral needs π‘₯(𝑠) and 𝑦(𝑠) to have square integrable derivatives, and πœ†(𝑠) just has to be integrable. The simplest way of doing this is to let π‘₯(𝑠) and 𝑦(𝑠) be piecewise linear, and πœ†(𝑠) be piecewise constant. You’ll find (once you factor πœŒπ‘” out of πœ†)

    0=πœ†π‘–βˆ’12π›Ώπ‘–βˆ’12(π‘₯π‘–βˆ’π‘₯π‘–βˆ’1)+πœ†π‘–+12𝛿𝑖+12(π‘₯π‘–βˆ’π‘₯𝑖+1),0=12π›Ώπ‘–βˆ’12+12𝛿𝑖+12+πœ†π‘–βˆ’12π›Ώπ‘–βˆ’12(π‘¦π‘–βˆ’π‘¦π‘–βˆ’1)+πœ†π‘–+12𝛿𝑖+12(π‘¦π‘–βˆ’π‘¦π‘–+1),1=(π‘₯𝑖+1βˆ’π‘₯𝑖)2𝛿𝑖+122+(𝑦𝑖+1βˆ’π‘¦π‘–)2𝛿𝑖+122.

    which you solve on 0=𝑠0<𝑠1<…<π‘ π‘βˆ’1<𝑠𝑁=𝐿 with π‘₯0=βˆ’π‘Ž, π‘₯𝑁=π‘Ž, 𝑦0=𝑦𝑁=0 probably by using Newton iteration from some initial guess (the linear algebra is sparse).

  5. 5When the AI folk start muttering about β€œhidden structure on the latent manifold” I feel a strong urge to describe HMC as β€œiterated stochastic symplectic transformations on the cotangent bundle of the latent manifold”.