# Variation of a term in the Lagrangian

I don't understand why $$\frac{\delta}{\delta\phi}\left(\frac12\partial^\mu\phi\partial_\mu\phi\right)~=~\partial^\mu\partial_\mu\phi.\tag{1}$$

If we use integration by parts, there should be a minus sign, right? Shouldn't $\frac12$ still be there? Or are we saying that $$\frac{\delta}{\delta\phi}\left(\frac12\partial^\mu\phi\partial_\mu\phi\right) =\frac12\partial^\mu\left(\frac{\delta}{\delta\phi}\phi\right)\partial_\mu\phi =\partial^\mu\partial_\mu\phi.\tag{2}$$

In this answer we will just make a general conceptional remark about variational/functional derivative (FD), which hopefully implicitly answers OP's specific questions.

OP is apparently considering the 'same-spacetime' FD,

$$\tag{A}\frac{\delta {\cal L}(x)}{\delta\phi^{\alpha} (x)}~:=~ \frac{\partial{\cal L}(x) }{\partial\phi^{\alpha} (x)} - d_{\mu} \left(\frac{\partial{\cal L}(x) }{\partial\partial_{\mu}\phi^{\alpha} (x)} \right)+\ldots.$$

[We use the symbol $d_{\mu}\equiv\frac{d}{d x^{\mu}}$ (rather than $\partial_{\mu}\equiv\frac{\partial}{\partial x^{\mu}}$) to stress the fact that the derivative $d_{\mu}$ is a total derivative, which involves both implicit differentiation through the field variables $\phi^{\alpha}(x)$, and explicit differentiation wrt. $x^{\mu}$. The ellipsis $\ldots$ in eq. (A) denotes possible contributions from higher-order spacetime derivatives.]

The 'same-spacetime' FD is designed to yield shorter notation and reproduce the well-known Euler-Lagrange formula for the variational/functional derivative.

But it is important to stress that the 'same-spacetime' notation (A) is conceptually misleading: We are not varying the Lagrangian density ${\cal L}(x)$ wrt. the field $\phi^{\alpha} (x)$ in the same spacetime point $x$, as the notation (A) may suggest. We are really varying the action functional $S=\int\! d^ny~{\cal L}(y)$ wrt. the field $\phi^{\alpha} (x)$.

The functional derivative $\frac{\delta}{\delta \phi}$ acts on functionals, things that map functions to real numbers. That is, they act on actions $S$, not lagrangians $L$. I don't know where you got your original question, but there indeed should be a minus sign! Altogether, I think what you're asking is why: $$\frac{\delta}{\delta \phi} \int d^4x \left(\frac{1}{2} \partial^\mu \phi \partial_\mu \phi\right) = - \partial^\mu \partial_\mu \phi \ .$$

There are quick formulas you can look up, but for understanding I always find it easiest to work through the variation directly. First, take your term $\frac{1}{2} \partial^\mu \phi \partial_\mu \phi$ and do the transformation $\phi \to \phi + \delta \phi$:

\begin{align*} \frac{1}{2} \partial^\mu \phi \partial_\mu \phi &\to \frac{1}{2} \partial^\mu (\phi+\delta \phi) \partial_\mu (\phi + \delta \phi) \\ &= \frac{1}{2} \partial^\mu \phi \partial_\mu \phi + \frac{1}{2} \partial^\mu (\delta \phi) \partial_\mu \phi + \frac{1}{2} \partial^\mu \phi \partial_\mu (\delta \phi) + \mathcal{O}(\delta\phi^2) \end{align*}

Now you can probably see where this is going, the $1/2$ will be accounted for by the two $\delta \phi$ terms in the expansion. This is really just product rule!

To extract the $\delta \phi$ you can integrate each term by parts, dropping the total derivative because this is physics and everything is 0 on the boundary :)

\begin{align*} \delta \int d^4x \left(\frac{1}{2} \partial^\mu \phi \partial_\mu \phi\right) &= \int d^4 x\left(-\frac{1}{2}\delta \phi \ \partial^\mu \partial_\mu \phi - \frac{1}{2}\partial_\mu\partial^\mu \phi \ \delta \phi + \partial_\mu(\dots) \right )\\ &= \int d^4 x \ \delta \phi \left( -\partial^\mu \partial_\mu \phi \right) \end{align*} The answer is just the integrand, without the $\delta \phi$, so finally we write: $$\frac{\delta}{\delta \phi} \int d^4x \left(\frac{1}{2} \partial^\mu \phi \partial_\mu \phi\right) = - \partial^\mu \partial_\mu \phi \ .$$

Section 9.2 of Peskin & Schroeder runs through the axioms of functional integration if you'd like to see a more formal take on it.