When the spacing between the plates is doubled, the capacitance of the capacitor
is halved to pF. If the battery is disconnected then this process
takes place at constant charge . Thus, it follows from the
formula

that the energy stored in the capacitor doubles. So, the new energy is J. Incidentally, the increased energy of the capacitor is accounted for by the work done in pulling the capacitor plates apart (since these plates are oppositely charged, they attract one another).

If the battery is left connected, then the capacitance is still halved, but now
the process takes place at constant voltage . It follows from the
formula

that the energy stored in the capacitor is halved. So, the new energy is J. Incidentally, the energy lost by the capacitor is given to the battery (in effect, it goes to re-charging the battery). Likewise, the work done in pulling the plates apart is also given to the battery.