Solution (source code)

= Solution

Use the free <Hamiltonian operator> and the <canonical commutation relations>. The kinetic momentum term gives
$$
[H_1,\phi_1(t,\mathbf x)]
=\frac12\int d^3y\,[\pi_1(t,\mathbf y)^2,\phi_1(t,\mathbf x)]
=-i\pi_1(t,\mathbf x).
$$
The <Heisenberg picture> equation therefore yields $\dot\phi_1=\pi_1$.

For the momentum commutator, the mass term gives $im_1^2\phi_1(\mathbf x)$. The gradient term gives
$$
\frac12\int d^3y\,[(\nabla\phi_1(\mathbf y))^2,\pi_1(\mathbf x)]
=i\int d^3y\,\nabla\phi_1(\mathbf y)\cdot\nabla_{\mathbf y}\delta^{(3)}(\mathbf y-\mathbf x)
=-i\nabla^2\phi_1(\mathbf x),
$$
where <integration by parts> differentiates the field instead of the <Dirac delta distribution>. Thus
$$
[H_1,\pi_1]=i(m_1^2-\nabla^2)\phi_1,\qquad
\dot\pi_1=(\nabla^2-m_1^2)\phi_1.
$$
Combining the two first-order operator equations gives the <Klein-Gordon equation>:
$$
\boxed{(\partial_t^2-\nabla^2+m_1^2)\phi_1=(\Box+m_1^2)\phi_1=0.}
$$
Suitable decay or spatial smearing removes the boundary term in the integration by parts.