how to calculate the energy stored in a capacitor