Q:

Derivation of variation

$$\delta S=2\int dx^+dx^-\left(\frac{\partial\delta \phi}{\partial x^+}\frac{\partial \phi}{\partial x^-}+\frac{\partial \phi}{\partial x^+}\frac{\partial\delta \phi}{\partial x^-}\right)=-4\int dx^+dx^-\frac{\partial^2\phi}{\partial x^+\partial x^-}\delta\phi \tag{1}$$
This variation leads to the equation of motion.
Can someone explain the the step from the middle equation to the right hand side?
I dont know how to take the derivative of $\frac{\partial \delta \phi}{\partial x}$.

A:

Hint: you can integrate by parts
$$\int_{-\infty}^\infty\text{d}x\frac{\partial f}{\partial x}\frac{\partial g}{\partial x}=\left[\frac{\partial f}{\partial x}g(x)\right]_{-\infty}^{\,\infty}-\int_{-\infty}^\infty\text{d}x\frac{\partial^2 f}{\partial x^2}g(x)$$
In these types of calculations you can  always neglect the boundary term, $\left[\frac{\partial f}{\partial x}g(x)\right]_{-\infty}^{\,\infty}=0\,,$ so essentially you can move a derivative from one factor to the other at the cost of a minus sign.

