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)}$$