Coulomb potential energy functional derivative I'm having problem understanding how to compute a functional derivative when it's involved more than one integral, such as the coulomb potential energy functional:
$$ J[\rho] = \frac 12\int \frac{\rho(r)\rho(r')}{|r - r'|} drdr' $$
According to the functional derivative formula I should do something on these lines:
$$ \frac {\delta J}{\delta \rho (r)} = \frac{\partial}{\partial \rho(r)} [ \frac 12 \int \frac{\rho(r) \rho(r')}{|r - r'|}dr' ]$$
In my wrong reasoning I would simply take $\rho(r) $ out of the integral and apply the derivative:
$$\frac {\partial \rho(r)}{\partial \rho(r)} \frac 12 \int \frac{\rho(r')}{|r - r'|} dr' = \frac 12 \int \frac{\rho(r')}{|r - r'|} dr'$$
Which is wrong because the correct result should be:
$$\int \frac{\rho(r')}{|r - r'|} dr'$$
1) I'm quite confused by the notation and how to treat a partial derivative by $\rho(x)$
2) What's the correct way to handle and compute functional derivatives in these cases? I'm actually in a similar situation with a much complex derivative, such as the same thing in the density matrix formalism:
$$ J[\gamma_1] = \frac 12 \int \frac{\gamma_1 (x_1', x_1) \gamma_1 (x_2', x_2) \delta(x_1' - x_1) \delta(x_2' - x_2) dx_1 dx_1' dx_2 dx_2'}{|x_1 - x_2|}$$
$$\frac {\delta J[\gamma_1]}{ \delta \gamma_1 (x_1'. x_1)}$$
 A: Alternatively, consider a slight perturbation $\rho+\lambda$ of $\rho$. Ignoring terms in $\lambda^2$, we have
$$J[\rho+\lambda]=\frac{1}{2}\int\frac{\rho(r)\rho(r')}{|r-r'|}drdr'+\frac{1}{2}\int\frac{\lambda(r)\rho(r')}{|r-r'|}drdr'+\frac{1}{2}\int\frac{\rho(r)\lambda(r')}{|r-r'|}drdr',$$
which simplifies, interchanging the integration variables, to
$$J[\rho+\lambda]=\frac{1}{2}\int\frac{\rho(r)\rho(r')}{|r-r'|}drdr'+ \int\frac{\rho(r')}{|r-r'|}dr'\lambda(r)dr.$$
This is what one usually means when one says 
$$\frac{\delta J[\rho]}{\delta \rho(r)}=\int\frac{\rho(r')}{|r-r'|}dr',$$
as in genneth's answer. (This is in the same spirit as that $\int_{-\infty}^\infty e^{ik(x-y)}dk=2\pi\delta(x-y)$ really says that $\int_{-\infty}^\infty\left(\int_{-\infty}^\infty e^{ik(x-y)}dk\right)f(y)dy=2\pi f(x)$ for reasonable $f$.)
A: Just like in normal differentiation, you can get yourself confused if you call all your variables the same thing. So let's write things carefully:
$$ J[\rho] = \frac 12\int \frac{\rho(r)\rho(r')}{|r - r'|} dr\,dr' $$
and the functional derivative will use a different dummy variable:
$$ \frac {\delta J}{\delta \rho (x)} = \frac{\delta}{\delta\rho(x)} \left[ \frac 12 \int \frac{\rho(r) \rho(r')}{|r - r'|}dr\,dr' \right] $$
We use the identity:
$$ \frac {\delta \rho(y)}{\delta \rho(x)} = \delta(x-y) $$
and simply proceed exactly as a normal derivative:
$$ \begin{align*}
\frac {\delta J}{\delta \rho (x)} &= \frac 1 2 \int \frac{\delta(r-x) \rho(r') + \rho(r) \delta(r'-x)}{|r - r'|}dr\,dr'\\  
& = \int \frac{\rho(r)}{|x-r|}dr
\end{align*}$$
