I have been working on a problem about finding the electrostatic potential energy stored on a capacitor of concentric spheres with inner radius $a$ and outer radius $b$ and with charge $Q$. I've got to first calculate the energy using the capacitance and then integrating the energy density.
I did the following: first of all I've used Gauss' Law to find the electric field a distance $r$ from the center of both spheres with $a < r < b$. As expected I've got the field of a point charge $Q$ at the center. Then I've integrated the field along a segment joining the two spheres and I've got the following difference of potential
$$V=\frac{1}{4\pi\epsilon_0}\frac{Q(a-b)}{ab}$$
Then I've found the capacitcante using $Q=CV$ and finally I've found the energy using $U=Q^2/2C$. That's fine, I've got the value:
$$U_1=\frac{1}{8\pi\epsilon_0}\frac{Q^2(a-b)}{ab}$$
Now the second part, I should find the same value integrating the energy density. So, the energy density is $\mathcal{u}=\epsilon_0E^2/2$ and hence it is:
$$\mathcal{u}=\frac{1}{2}\epsilon_0 \frac{1}{16\pi^2\epsilon_0^2}\frac{Q^2}{r^4}$$
Since I must integrate on the region between the two spheres I've used spherical coordinates and computed the following integral getting the energy:
$$U_2=\int_0^\pi\int_0^{2\pi}\int_a^b \frac{1}{2}\epsilon_0 \frac{1}{16\pi^2\epsilon_0^2}\frac{Q^2}{r^4}r^2\sin\phi dr d\theta d\phi$$
And this integral gave simply:
$$U_2 =\frac{1}{8\pi\epsilon_0}\frac{Q^2(b-a)}{ab}$$
But wait a moment, I've got $U_2 = -U_1$ instead of $U_2 = U_1$ as expected. I've calculated it once again and once again and I've got the same problem. Can someone point out what's happening? Where's my mistake?
Thanks in advance for your help!