Gauss' law from Hamiltonian density of electromagnetic field I am going through David Tong's QFT course, for which lecture notes and exercises are available online at http://www.damtp.cam.ac.uk/user/tong/qft.html.
In Question 1.8 we have the Lagrangian (density)
$$L = -\frac{1}{4} F^{\mu \nu} F_{\mu \nu} + \frac{1}{2} m^2 C_\mu C^\mu,$$
$$F_{\mu \nu} = \partial_\mu C_\nu - \partial_\nu C_\mu,$$
which is like the standard electromagnetic field in the case $m=0$.
I eventually derive the conjugate momenta $\Pi_\mu$ to $C_\mu$ and convert the Lagrangian to a Hamiltonian
$$H = -\frac{1}{2} \Pi_i \Pi^i + \frac{1}{4}F^{ij}F_{ij} - \frac{1}{2} m^2 C^{\mu}C_{\mu} - \Pi_i \partial^i C_0,$$
answering the question.
However in a pdf of tutor's solutions I came across online (which I maybe shouldn't link), the tutor comments and interprets further:
they rearrange the last term,
$$H = -\frac{1}{2} \Pi_i \Pi^i + \frac{1}{4}F^{ij}F_{ij} - \frac{1}{2} m^2 C^{\mu}C_{\mu} - C^0(\partial_i \Pi^i) - \partial_i (\Pi^i C^0),$$
and comment

[the term] involves an irrelevant three-divergence term.  Since the remainder of the Hamiltonian contains no derivatives in $C^0$, $C^0$ may be regarded as a multiplier that, in the $m=0$ theory, imposes the constraint $\nabla \cdot \Pi = m^2 C^0 = 0$, which is precisely Gauss' law.

Since we are back to examining the $m=0$ case, this is a statement about the standard electromagnetic field.
I don't understand either statement here.
How is $\partial_i (\Pi^i C^0)$ "irrelevant"?  Can we just ignore this divergence, which as far as I can see has a nonzero value?
$- C^0(\partial_i \Pi^i)$ could be a (Lagrange) multiplier, how is it rearranged to include the $m^2$ term and (together) constrain to $\nabla \cdot \Pi=0$?
 A: Main points:

*

*A total spacetime divergence in the Lagrangian (or Hamiltonian) does not change the EOMs, cf. e.g. this Phys.SE post.


*If we know that the fields vanishes on the boundary, e.g. by imposing pertinent boundary conditions, we can use the divergence theorem to argue that a divergence term cannot contribute to, say the EM energy.


*The EOM for $C_0$ reads $\nabla \cdot \Pi = m^2 C^0$.


*In the massless limit $m=0$, this EOM becomes Gauss's law in vacuum.
A: What you found is actually the Hamiltonian Density $\mathcal{H}$. The Hamiltonian is the spatial integral of Hamiltonian Density
\begin{equation}
H=\int_\mathcal{M} d^Nx\,\mathcal{H}(x).
\end{equation}
If you have an spatial divergence in your Hamiltonian Density, its contribution to the Hamiltonian can be converted into a hypersurface integral using divergence theorem
\begin{equation}
\int_\mathcal{M} d^Nx\,\partial_i\Pi^i=\int_{\partial\mathcal{M}}d\sigma\,n_i \Pi^i,
\end{equation}
where $\partial\mathcal{M}$ is the boundary hypersurface, and $n_i$ is the normal vector to it. As that boundary is in infinite, where $\Pi^i$ must vanish, the contribution of the $\partial_i\Pi^i$ term to the Hamiltonian Density is nule.
The Lagrange multiplier would be just $C_0$ in the $m^2=0$ case, enforcing $\partial_i \Pi^i=0$. When $m^2\neq0$ that constraint is not true.
