Work producing current = energy stored in the magnetic field? It is stated that "the formula for the energy stored in the magnetic field is: $$E =  \left(\frac{1}{2}\right)(LI)^2$$ and the energy stored in the magnetic field is equal to the work done to produce the current.
What is the formula for  work , that shows they are equal? 
I understand they are equal due to conservation of energy, but I'd like to see the mathematical operation to support my understanding. 
 A: Power is, in words, the rate at which work is done and work done equals the amount of energy converted from one form to another.
For electric circuits, the power associated with a circuit element is the product of the voltage across and the current through.
We can verify this via dimensional analysis:
$$v \cdot i = \frac{J}{C}\cdot \frac{C}{s} = \frac{J}{s}$$
Where we use the passive sign convention, the power is positive if power is delivered to the circuit element and negative when power is supplied by the circuit element.
For an inductor, we have
$$v_L = L \frac{di_L}{dt}$$
thus, the power associated with an inductor is
$$p_L = v_Li_L = Li_L\frac{di_L}{dt}$$
The work, due to the current through and voltage across is then
$$w(t) = \frac{1}{2}Li(t)$$
But this is just the equation for the energy stored in the magnetic field (as it must be).
Additional insight can be gained by looking at mechanical-electrical analogies.
For example, the product of force and velocity is mechanical power.
We are free to choose which mechanical variable is analogous to which electrical variable.  So, if we choose velocity analogous to current (thus, force analogous to voltage) then an inductor is analogous to a mass.
$$F = m\dfrac{dv}{dt} \Leftrightarrow v = L \frac{di}{dt}$$
Then, the mass's kinetic energy (equal to the work done on the mass) is analogous to the inductor's magnetic energy (equal to the work done on the inductor):
$$\frac{1}{2}mv^2 \Leftrightarrow \frac{1}{2}Li^2$$
A: Starting from the definition of power
$$P=\frac{dW}{dt}$$
We can solve for the work (after integrating). The thing to know is what power is in terms of current and voltage or resistance
$$P=IV=I^2R=V^2/R$$
Clearly, $P=IV$ is what we want to use. Last thing is what is $V$ for a inductor? It is $V=L\frac{dI}{dt}$
From here I will let you (and future users) work out the details and put all the pieces together. But of course let me know if you need any clarification!
