When is numerical value of Lagrangian evaluated on-shell a full differential? I noticed recently that for many field equations, Lagrangian evaluated on-shell (i.e. using equations of motions) is a full derivative- a divergence or something, or in other words a boundary term. This is true for Weyl, Dirac, Klein-Gordon (without external potential), Maxwell, classical Schrodinger. I am wondering if these are special cases of some general pattern or principle.
 A: Theorem: let $L$ be a homogeneous function of degree $k$; then the on-shell lagrangian is a total derivative.
Proof: according to the Euler's homogeneous function theorem,
$$
k\ L(q,\dot q)=q\frac{\partial L}{\partial q}+\dot q\frac{\partial L}{\partial \dot q}\tag{1}
$$
On the other hand, because of the Euler-Lagrange equations,
$$
(1)=q\frac{\partial L}{\partial q}+\dot q\frac{\partial L}{\partial \dot q}\stackrel{\mathrm{EL}}{=}q\frac{\mathrm d}{\mathrm dt}\left(\frac{\partial L}{\partial \dot q}\right)+\dot q\frac{\partial L}{\partial \dot q} \tag{2}
$$
Finally, integrating by parts,
$$
(2)=q\frac{\mathrm d}{\mathrm dt}\left(\frac{\partial L}{\partial \dot q}\right)+\dot q\frac{\partial L}{\partial \dot q}\stackrel{\mathrm{IBP}}{=}-\dot q\frac{\partial L}{\partial \dot q}+\dot q\frac{\partial L}{\partial \dot q}+\text{total derivative}=\text{total derivative}\tag{3}
$$
which is what we wanted to prove. The generalisation to field theory is straightforward.

As for an example of a non-homogeneous lagrangian, take
$$
L=\frac{1}{2}\dot q^2+\mathrm e^q\tag{4}
$$
which, when evaluated on-shell, is
$$
L=\mathrm e^q\left(1-\frac{q}{2}\right)\tag{5}
$$
i.e., this is not a total derivative. For a more realistic example, see QMechanics comment above ("a non-relativistic point particle in a uniform gravitational field").
