Solution (source code)

= Solution

For an infinitesimal field variation $\delta\phi$ such that $\delta\mathcal L=\partial_\mu K^\mu$, integration by parts gives
$$
\delta\mathcal L=
\left(\frac{\partial\mathcal L}{\partial\phi}
-\partial_\mu\frac{\partial\mathcal L}{\partial(\partial_\mu\phi)}\right)\delta\phi
+\partial_\mu\left(
\frac{\partial\mathcal L}{\partial(\partial_\mu\phi)}\delta\phi\right).
$$
On the <Euler-Lagrange equations>, <Noether's theorem> therefore gives
$$
j^\mu=\frac{\partial\mathcal L}{\partial(\partial_\mu\phi)}\delta\phi-K^\mu,
\qquad \partial_\mu j^\mu=0.
$$
For transformations of spacetime, the variation at fixed coordinates and the change of the integration measure give the corresponding <energy-momentum tensor> terms.