Initial capacitance,
The energy of the capacitor before the insertion of the dielectric is given by
After inserting the dielectric slab, the capacitance becomes
and the final voltage becomes
Thus, the final energy stored in the capacitor is given by
Now,
Work done = Change in energy
∴ W = E2 E1