Suppose a capacitor having capacitance $C$ is being charged using a cell of emf $E$. By the time the capacitor is fully charged, the cell has supplied $QV$ energy while the potential energy of the capacitor is $QV/2$. So there is a net loss of $QV/2$ joules of energy. Where is the energy lost? Since it is an ideal circuit, there is no resistance and there should be no heat loss. Can anyone tell me which assumption do we make and where do we make it while setting up the ideal circuits and deriving their formulas which is the reason for the loss of energy?
Also, why isn't energy lost when we pull out a dielectric slab from between the plates of a charged capacitor which is connected across a cell? The slab is moved without changing its kinetic energy.