Energy stored in the magnetic field While deriving energy density of a  magnetic field via using an inductor, why dont we consider the energy stored outside of inductor also? 
As initially the field was there outside the inductor, (may be very very far away), but afterwards it is gone..and along woth it the energy stored in it..
If this energy outside the inductor doesnt come in form of heat through resistor , then where does it go? 
I am talking about the derivation in which an ideal inductor carrying current i is brought in contact with resistor and heat liberated through resistor ($\frac12LI^2$) = energy stored outside inductor + energy stored inside inductor.
I dont understand how people put that outside energy term = 0.
As many field lines would exist inside inductor.. So many would outside
 A: If you observe in the formula you have energy described by using some geometrical and material characteristics of the wires in the coil and the intensity of the current. 
So there is no term relating energy to something outside the coil. 
The answer to that is because we are dealing here with a static magnetic field which is felt only by the electrons of this coil alone. 
In dynamical regime we have the self-induction which is due to the field of the coil oscillating and inducing an extra electromotive force in the same coil. 
IF we had an external independent magnetic field around our circuit, then yes we needed to include that too in the equation.
A: I'll assume that your inductor is a common sort, a long coil of wire. Then as we establish a current through it, it will produce magnetic flux. The lines of flux are closed loops linked with the coil, and therefore partly inside and partly outside the coil. The usual way to derive the energy stored by the inductor is by considering the emf induced in the coil, which we have to do work against, as we increase the current. This emf is equal to the rate of change of flux linkage with the coil, and does not favour field outside or field inside. [It is true that in order to evaluate the flux linkage at any time we may consider 'lines' crossing the internal area of the coil (that is, neglecting non-uniformity of field at the ends of the coil) calculate $$N \Phi=NBA_\text {int}$$ but we could equally well consider an area outside the coil, stretching from the outside circumference of the coil (around its middle) to infinity and evaluate $$N \Phi=N \int_{A_\text{ext}} \vec{B}.\vec{dA}.$$ This area will be crossed by the same lines as crossed the area inside the coil!]
Another way to evaluate the energy stored is to integrate up the energy stored in the magnetic field in and around the coil, in other words to use $$U=\int _{V} \frac{1}{\mu_0}B^2(I)\ dV$$ This makes the point very clearly that both 'inside' and 'outside' contribute towards the energy.
