Consider the harmonic oscillator, for which the general solution is
x(t)=Acosωt+Bsinωt.
Express the energy in terms of A and B and note that it does not depend on time. Now choose A and B such that x(0)=x1 and x(T)=x2. Write down the energy in terms of x1, x2, and T. Show that the action for the trajectory connecting x1 and x2 is
Scl(x1,x2,T)=2sinωTmω[(x12+x22)cosωT−2x1x2].
Verify that ∂Scl/∂T=−E.