Initially, after a steady current is set up, the current is flowing as shown. In steady condition
When the switch is disconnected, the current through R changes from i10 to the right, to i20 to the left. (The current in the inductance cannot change suddenly.). We then have the equation,
This equation has the solution
The heat dissipated in the coil is,