I am currently reading through my electrodynamics lecture notes and I can't understand a calculation.
$$ E = \frac{1}{2} \int \mathrm{d}^3x \, \phi(\mathbf{x}) \rho(\mathbf{x}) = - \frac{\epsilon_0}{8\pi} \int \mathrm{d}^3x \, \phi(\mathbf{x}) \Delta \phi(\mathbf{x}) \\ = \frac{\epsilon_0}{8\pi} \int \mathrm{d}^3x \, \nabla \phi(\mathbf{x}) \nabla \phi(\mathbf{x}) = \frac{1}{8\pi} \int \mathrm{d}^3x \, \mathbf{D} \cdot \mathbf{E}$$
I know the identity $\nabla ( f \nabla g) = \nabla f \cdot \nabla g + f \Delta g$ which I could easily prove by looking at the components and summing. I think I have to use this identity from the first to second line in the above equation but I don't know why $\int \mathrm{d}^3x \, \nabla (\phi \nabla \phi) = 0$. I tried using $\nabla \phi = -\mathbf{E}$ and the divergence theorem but I couldn't show that.
The question is pretty specific and you don't get much insight from it but I would really like some help.