Energy density in Gross-Pitaevskii equation I guess this is a straightforward question but I was wondering if I can get an explicit steps toward the answer.  
Using the Gross-Pitaevskii equation:
$$ \tag{1} i \hbar\frac{\partial\psi\left(x,t\right)}{\partial t} =\left(-\frac{\hbar^{2}}{2m} \nabla^{2} + V_{ext}  + g \left|\psi\left(x,t\right)\right|^{2} \right) \psi\left(x,t\right)$$
With the variational relation:
$$\tag{2} i \hbar\frac{\partial\psi}{\partial t} = \frac{\delta\epsilon}{\delta \psi^{*}}$$
We can find the energy density by equating the right hand side of equation (1) and equation (2). 
$$ \tag{3} \frac{\delta\epsilon}{\delta \psi^{*}} = \left(-\frac{\hbar^{2}}{2m} \nabla^{2} + V_{ext}  + g \left|\psi\left(x,t\right)\right|^{2} \right) \psi\left(x,t\right)$$
By integrating both sides of equation (3) over $\psi^{*}$ we get:
$$ \tag{4} \epsilon \left[\psi \right] = \left(\frac{\hbar^{2}}{2m} \left|\nabla \psi\right|^{2} + V_{ext} \left|\psi\right|^{2} + \frac{g}{2} \left|\psi\right|^{4}
\right)$$
My question is:
What are the explicit steps to get equation (4) from equation (3) ?
In my calculations I have a problem only in getting the factor $\frac{g}{2}$ in the last term in equation (4) and also getting   $\epsilon[\psi]$ from $\frac{\delta\epsilon}{\delta \psi^{*}}$.
Thank you!
 A: First of all, the form of eq-n (4) is usually just guessed from eq-n (3). It's almost like integration. Let's try to check term-by-term backwards (which will allow us to put the right coefficients).
First term:
$$
\frac{\delta}{\delta \psi^\dagger}\left|\nabla \psi\right|^2=\frac{\delta}{\delta \psi^\dagger}\nabla\psi\cdot\nabla\psi^\dagger=\nabla\psi^\dagger\cdot\frac{\delta}{\delta \psi^\dagger}\nabla\psi+\nabla\psi\cdot\frac{\delta}{\delta \psi^\dagger}\nabla\psi^\dagger=0+\nabla\psi\cdot\frac{\delta}{\delta \psi^\dagger}\nabla\psi^\dagger=\\=\left|\text{ integrating by parts & setting surface part to zero }\right|=-\nabla^2\psi
$$
Second term:
$$
\frac{\delta}{\delta \psi^\dagger}\left|\psi\right|^2=\frac{\delta}{\delta \psi^\dagger}\psi\psi^\dagger=0+\psi=\psi
$$
Third term:
$$
\frac{\delta}{\delta \psi^\dagger}\left|\psi\right|^4=\frac{\delta}{\delta \psi^\dagger}\psi\psi^\dagger\psi\psi^\dagger=0+\psi\psi\psi^\dagger+0+\psi\psi^\dagger\psi=2\left|\psi\right|^2\psi
$$
I used the fact that $\delta\psi/\delta\psi^\dagger=0$. Remember, that $\psi$ and $\psi^\dagger$ are thought independent here. 
So the method is pretty much by guessing, but, as you see, it's not difficult to guess.
UPD How's the integration by parts done?
A functional derivative is defined from the variation, so let's try to write the functional variation of $E=\int \epsilon[\psi]\mathrm{d}^3 x$ (first term).
$$
\delta E^{(1)}=\int_\Omega\mathrm{d}^3x\left[\nabla\psi\cdot \delta \nabla\psi^\dagger\right]=\left|\text{ $\delta$ and $\nabla$ can be swapped }\right|=\\
=\int_\Omega\mathrm{d}^3x\left[\nabla\psi\cdot \nabla \delta\psi^\dagger\right]=\left|\text{ integrating by parts }\right|=\\
=\int_S\delta\psi^\dagger\nabla\psi\cdot\mathbf{\mathrm{d}\Gamma}-\int_\Omega\mathrm{d}^3x\left[\nabla^2\psi \delta\psi^\dagger\right]
$$
In $\delta E^{(1)}$ the first term is zero, as $\delta\psi^\dagger\biggr\rvert_S=0$. So $\delta E^{(1)}/\delta\psi^\dagger=\int_\Omega \mathrm{d}^3x\left[-\nabla^2\psi\right]$.
