Heat produced when dielectric inserted in a capacitor When a capacitor is connected to battery, it stores $\frac{C V^2}{2}$, while battery supplied $CV^2$ energy. Therefore, $\frac{C V^2}{2}$ energy gets lost as heat. When a capacitor is already charged and a dielectric is inserted in this charged capacitor (which is still connected to the battery), will there be any heat produced ?
 A: The calculation by Ben clearly shows that the total energy stored in the battery and the capacitor is lower for the final situation than for the initial situation. Some energy has thus gone somewhere else.
The question is: Where did this energy go? And are we allowed to calculate to force on the dielectric by taking the derivative of the energy with respect to the position of the dielectric?
The answer is that it depends on in what way you let the dielectric slide into the capacitor. (I consider a solid dielectric here)
If the dielectric is slowly inserted into the capacitor, there will be no energy converted into heat at all. A force is needed to prevent the dielectric from sliding in. The dielectric is thus performing work on the object that is holding it back. All the missing energy will be transferred to the object holding back the dielectric. 
In this situation calculating the force from the change in energy is justified.
Note that in this situation, the voltage over the capacitor will remain constant during the insertion of the dielectric and the current that is required to charge the capacitor can be made arbitrarily low by choosing a low enough insertion velocity.
The situation changes when instead of slowly inserting the dielectric, you let go of the dielectric and it is just left to move freely into the capacitor. In that case a large current is needed to increase the charge on the capacitor. The electrical resistance in the circuit will dissipate some energy into heat. The rest of the energy is converted into kinetic energy of the dielectric. 
If there is little mechanical resistance, the dielectric will shoot out the other side of the capacitor and will be pulled back again. It will oscillate in this way, until the oscillations are damped by the electrical and mechanical resistance.
In this case it is not justified to calculate the force by just considering the energy in the capacitor and battery. One should also consider the energy dissipated in the resistance.
Note that in this case the voltage over the capacitor is no longer constant. The voltage drop over the electrical resistance will cause a voltage difference between the battery and the capacitor.
A: Yes, because when you add the dielectric more charge will flow onto the plates of the capacitor.
The energy on the capacitor is initially:
$$E_{c,i} = \frac{1}{2}CV^2   $$
After you add the dielectric:
$$E_{c,f} = \frac{1}{2}C'V^2   $$
So the change in energy is:
$$\Delta E_{c} = \frac{1}{2}V^2 (C'-C)$$
However, for the battery,
$$E_{B,i} = CV^2   $$
$$E_{B,f} = C'V^2   $$
$$\Delta E_{B} = V^2 (C'-C)$$
Finally,
$$\Delta E_B - \Delta E_c = \frac{1}{2}V^2 (C'-C)$$
which is the amount of heat produced.
