Inside `(r gt R)`
`E = (1)/(4 pi in_(0)).(Qr)/(R^(3))`
`dV = 4 pi r^(2) dr`
`dU = udV = (1)/(2) in_(0) E^(2) dV`
`= (1)/(2) in_(0) ((1)/(4pi in_(0)) .(Qr)/(R^(3)))^(2) 4 pi r^(2) dr`
`U_(in) = (Q^(2))/(8 pi in_(0) R^(6)) int_(0)^(R) r^(4) d r = (Q^(2))/(8 pi in_(0)R^(6)) (R^(5))/(5)`
`= (Q^(2))/(40 pi in_(0) R)`
Outside `(r gt R)`
`U_(out) = (Q^(2))/(8 pi in_(0) R)` (as proved in the previous example)
`U = U_(in) + U_(out)`
`= (3Q^(2))/(20 pi in_(0) R) = (1)/(4 pi in_(0)) .(3 Q^(2))/(20 pi in_(0) R) = (1)/(4 pi in_(0)).(3Q^(2))/(5R)`
If we want to calculate energy stored in a spherical shell of inner radius `R` and outer radius `2 R`.
`U = int_(R )^(2R) (1)/(2) in_(0) ((1)/(4 pi in_(0)) (Q)/(r^(2)))^(2) 4 pi r^(2) dr`
`= (Q^(2))/(8 pi in_(0)) int_(R)^(2R) r^(-2) dr = (Q^(2))/(16 pi in_(0) R)`