$$\require{cancel}$$
During the growth of the current in an inductor, at a time when the current is $$i$$ and the rate of increase of current is $$\dot i$$, there will be a back EMF $$L\dot i$$. The rate of doing work against this back EMF is then $$Li\dot i$$. The work done in time $$dt\text{ is }Li \dot i \,dt = Li\,di$$ where $$di$$ is the increase in current in time $$dt$$. The total work done when the current is increased from 0 to $$I$$ is
$\label{10.16.1}L\int_0^I i\,di = \frac{1}{2}LI^2,$