Maxwell's equations In general the demagnetizing field is a function of position . It is derived from the
magnetostatic equations for a body with no
electric currents. These are
Ampère's law {{NumBlk|:|\nabla\times\mathbf{H} = 0,|}} and
Gauss's law {{NumBlk|:|\nabla\cdot\mathbf{B} = 0.|}} The magnetic field and flux density are related by {{NumBlk|:|\mathbf{B} = \mu_0 \left(\mathbf{M}+\mathbf{H}\right), |}} where \mu_0 is the
permeability of vacuum and is the
magnetisation.
The magnetic potential The general solution of the first equation can be expressed as the
gradient of a
scalar potential : {{NumBlk|:|\mathbf{H} = -\nabla U.|}} Outside the body, where the magnetization is zero, {{NumBlk|:| \nabla^2 U_\text{out} = 0.|}} At the surface of the magnet, there are two continuity requirements: The outer potential must also be
regular at infinity: both and must be bounded as goes to infinity. This ensures that the magnetic energy is finite. Sufficiently far away, the magnetic field looks like the field of a
magnetic dipole with the same
moment as the finite body.
Uniqueness of the demagnetizing field Any two potentials that satisfy equations (), () and (), along with regularity at infinity, have identical gradients. The demagnetizing field is the gradient of this potential (equation ).
Energy The energy of the demagnetizing field is completely determined by an integral over the volume of the magnet: {{NumBlk|:|E = -\frac{\mu_0}{2}\int_\text{magnet} \mathbf{M}\cdot\mathbf{H}_\text{d} dV|}} Suppose there are two magnets with magnetizations and . The energy of the first magnet in the demagnetizing field of the second is {{NumBlk|:|E =\mu_0 \int_\text{magnet 1} \mathbf{M}_1\cdot\mathbf{H}_\text{d}^{(2)} dV.|}} The
reciprocity theorem states that {{NumBlk|:|\int_\text{magnet 1} \mathbf{M}_1\cdot\mathbf{H}_\text{d}^{(2)} dV = \int_\text{magnet 2} \mathbf{M}_2\cdot\mathbf{H}_\text{d}^{(1)} dV.|}}
Magnetic charge and the pole-avoidance principle Formally, the solution of the equations for the potential is {{NumBlk|:|U(\mathbf{r}) = -\frac{1}{4\pi}\int_\text{volume} \frac{\nabla'\cdot\mathbf{M\left(r'\right)}}dV' + \frac{1}{4\pi}\int_\text{surface} \frac{\mathbf{n}\cdot\mathbf{M\left(r'\right)}}dS',|}} where is the variable to be integrated over the volume of the body in the first integral and the surface in the second, and is the gradient with respect to this variable. Qualitatively, the negative of the divergence of the magnetization (called a
volume pole) is analogous to a bulk
bound electric charge in the body while (called a
surface pole) is analogous to a bound surface electric charge. Although the magnetic charges do not exist, it can be useful to think of them in this way. In particular, the arrangement of magnetization that reduces the magnetic energy can often be understood in terms of the
pole-avoidance principle, which states that the magnetization affects poles by limiting the poles (tries to reduce them as much as possible). ==Effect on magnetization==