Lagrangian and Integration by Parts Say I have a Lagrangian density with kinetic term $\mathcal{L}_{kin} = \phi \Box \phi$.
To derive the equations of motion, I could integrate by parts to obtain $\mathcal{L}_{kin}' = - (\partial_{\mu}\phi)(\partial_{\mu}\phi)$, then apply the Euler-Lagrange equations to obtain $2\Box\phi=0$. (Correct me if any of this is wrong, but this is the part I believe I understand.)
However, I am interested in how one would go about deriving the same equations of motion directly from $\phi\Box\phi$ without integration by parts. It seems there are two ways to go about it: treat the $\Box\phi$ factor entirely as a function of $\phi$, or entirely as a function of the $\partial_{\mu}\phi$ (or some combination of the two, but let's not overcomplicate things).
In both cases (which should yield equivalent results by the self-consistency of partial derivatives), it seems I get as the equation of motion $\Box\phi = 0$. In other words, I could equivalently treat the $\Box\phi$ as a constant, even though strictly speaking this is not correct. However, this equation differs by a factor of 2 from the other one. This would not be an issue if we just had the kinetic term, but it seems to me this could lead to problems if there were other terms in the Lagrangian, as now the relative scaling of terms could be different based on whether one does integration by parts or not.
What am I missing here? I imagine my misunderstanding has something to do with what occurs in the guts of the calculations $\frac{\partial}{\partial(\partial_{\mu}\phi)}\Box\phi$ and $\frac{\partial}{\partial\phi}\Box\phi$. Are these both 0, as I believe, or is the result more complicated?
 A: For what it's worth, the correct field-theoretic Euler-Lagrange (EL) equation reads in general
$$ 0~\approx~\frac{\delta S}{\delta\phi}
~=~\frac{\partial {\cal L}}{\partial\phi} 
-\sum_{\mu} \frac{d}{dx^{\mu}} \frac{\partial {\cal L}}{\partial (\partial_{\mu}\phi)} + \sum_{\mu\leq \nu} \frac{d}{dx^{\mu}} \frac{d}{dx^{\nu}} \frac{\partial {\cal L}}{\partial (\partial_{\mu}\partial_{\nu}\phi)} - \ldots,\tag{A} $$
where the $\approx$ symbol means equality modulo eoms, and the ellipsis $\ldots$ denotes possible higher-derivative terms.
If you include second-derivative terms, you will get the correct Klein-Gordon eom.
A: Varying the Lagrangian,
\begin{align}
\delta {\cal L} &=  \delta \phi \Box \phi + \phi \Box \delta \phi \\
&= \delta \phi \Box \phi  -  \partial_\mu \phi \partial^\mu \delta \phi +  \partial_\mu ( \phi \partial^\mu \delta \phi )  \\
&= 2 \delta \phi \Box \phi   +  \partial_\mu ( \phi \partial^\mu \delta \phi - \partial^\mu \phi \delta \phi )  \\
\end{align}
The E-L equations are obtained from the first term. The second term is a boundary term so it vanishes when integrated in the action.
A: Sometimes, rather than applying the Euler-Lagrange equations, one can use the functional derivative method directly to the action, namely, we have the equality,
$$\frac{\mathrm d}{\mathrm d \epsilon} S[\phi + \epsilon f] \Bigg\vert_{\epsilon=0} = \int\frac{\delta S}{\delta \phi}(x) f(x) \,\mathrm dx.$$
Then after applying appropriate boundary conditions and imposing $\delta S=0$ one obtains the equations of motion. While not pertinent to this question, this method is particularly useful when working with actions that are expressed in terms of differential forms.
