The demagnetizing field, also called the stray field (outside the magnet), is the magnetic field (H-field) generated by the magnetization in a magnet. The total magnetic field in a region containing magnets is the sum of the demagnetizing fields of the magnets and the magnetic field due to any free currents or displacement currents. The term demagnetizing field reflects its tendency to act on the magnetization so as to reduce the total magnetic moment. It gives rise to shape anisotropy in ferromagnets with a single magnetic domain and to magnetic domains in larger ferromagnets. The demagnetizing field of an arbitrarily shaped object requires a numerical solution of Poisson's equation even for the simple case of uniform magnetization. For the special case of ellipsoids (including infinite cylinders) the demagnetization field is linearly related to the magnetization by a geometry dependent constant called the demagnetizing factor. Since the magnetization of a sample at a given location depends on the total magnetic field at that point, the demagnetization factor must be used in order to accurately determine how a magnetic material responds to a magnetic field. (See magnetic hysteresis.) Magnetostatic principles 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 and Gauss's law The magnetic field and flux density are related by where 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 : Inside the magnetic body, the potential is determined by substituting () and () in (): Outside the body, where the magnetization is zero, At the surface of the magnet, there are two continuity requirements: The component of parallel to the surface must be continuous (no jump in value at the surface). The component of perpendicular to the surface must be continuous. This leads to the following boundary conditions at the surface of the magnet: Here is the surface normal and is the derivative with respect to distance from the surface. 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.