Examples of the Lagrangian

Scott A. Hughes, 18 October 2010

Begin by picking an initial velocity, give value of gravitational acceleration, mass, time that ball is in flight.

vx = 5;
vy0 = 5;
g = 10;
m=1;
T = 2vy0/g;

Equation describing height above ground as a function of time t.

y0[t_] = vy0 t - (1/2)g t^2;

Plot[y0[t],{t,0,T}]

A modified version of this equation, designed to see what happens as we deviate from the correct solution.  Notice that it is designed so that the initial (t = 0) and final (t = T) points coincide with the correct solution.

y1[t_] = y0[t](1 + ϵ Sin[20π t/T]);

The y-component of velocity for this modified trajectory.

vy1[t_] = D[y1[t],t];

The kinetic and potential energies corresponding to this trajectory.

K1[t_] = (m/2)(vx^2+vy1[t]^2);
V1[t_] = m g y1[t];

And the Lagrangian.

L1[t_] = Simplify[K1[t]-V1[t]]

Before computing the action, let's see what this trajectory looks like:

Plot[y1[t]/.ϵ->0.3,{t,0,T}]

OK, now compute the action for this Lagrangian.

S1[ϵ_] = Simplify[Expand[Integrate[L1[t],{t,0,T}]]]

Notice that this is that this is smallest for ϵ = 0!  For any non-zero value of ϵ, the action is larger than S1[0].

Just for fun, let's try a different modified trajectory: This just shifts the whole thing a bit, again making sure that the end points are in the correct place.

y2[t_] = y0[t](1 + ϵ t(T-t));

Plot[y2[t]/.ϵ->0.5, {t,0,T}]

vy2[t_] = D[y2[t],t];

K2[t_] = (m/2)(vx^2+vy2[t]^2);
V2[t_] = m g y2[t];

L2[t_] = Simplify[K2[t]-V2[t]]

S2[ϵ_] = Integrate[L2[t],{t,0,T}]

Once again, the action is smallest when ϵ = 0; any non-zero ϵ pushes us away from that minimum value.