# Relation between: density/twisted-ness of magnetic field lines and energy stored in the magnetic field

I am having difficulty reconcile the following two "intuition"s:

1. The denser the magnetic field is, the more energy it stores. we have seen many equations calculating flux involving B. For Example: energy stored in a solenoid: $$E=B^2*Area*Length/{\mu}$$

2. the more your distort the magnetic field between, lets say, two magnets, the more work you need to input into the two magnets, thus more energy is stored in the twisted field. This more of a view from the conservation of energy, the fields tend to align themselves to minimize potential energy within the system, and "even out" the space between the flux lines.

Now imagine two scenarios involving two bar magnets A and B:

1. [first scenario] two bar magnets places S to N touching, attracting each other in series, the junction between A's S and B's N contains almost all flux lines, that's pretty dense right? but the energy in this field should be zero. as the system has the lowest potential.
Now, if I attempt to explain why the energy in the field is zero saying "well, the volume is zero, energy is density * volume", Then the second scenario is waiting.

2. [second scenario] bringing A and B touching again, but N to N. I would have spent so much energy to bring those magnets together, fighting the repulsion between them, when A's N and B's N are touching, that field should really contain lots of energy. but the volume is zero?.

What I am missing here? I am suspecting many things.

• feel free to comment on any thing – ugn May 5 at 13:05