After inserting the dielectric the capacitance will be C′=kC
The charge flow through the cell when the slab insert is Q′=C′E=kCE
The charge flow through the cell when the slab is taken out =Q=CE
Net charge flow through the cell Qn=Q′−Q=kCE−CE=CE(k−1)
The amount of work for taking out slab is W=12(CkE2−CE2)=12CE2(k−1)