etotheipi
Adams2020 said:Do I have to use both electric fields? That is, I have to use both the electric field inside the sphere and outside the sphere ?
Yeah, you would need to split the integral into$$U = 2\pi \varepsilon_0 \int_0^\infty E^2 r^2 dr = 2\pi \varepsilon_0 \int_0^R \frac{k^2 Q^2 r^4}{R^6} dr + 2\pi \varepsilon_0 \int_R^\infty \frac{k^2 Q^2}{r^2} dr$$