In this article, we derive the magnetic field of a rectangular block magnet, a common magnetic geometry. We show how the geometry of the magnet allows for the analytical (albeit extremely tedious) evaluation of the magnetic potential and thus the magnetic field.

Note: The calculations of the near-field are incorrect and should be updated such that the result matches the analytical formula for given in Guide to modelling permanent magnets.

Near field of a block magnet

Let us assume that the magnets are of rectangular geometry, and have length , width , and depth , where the length is measured along the axis, the width is measured along the axis, and the depth is measured along the axis. Thus, the rectangular cuboid we are integrating over is defined by . As discussed in Guide to modelling permanent magnets, the magnetic scalar potential of a permanent homogeneous magnet is given by the following surface integral1:

Where is the magnetization of a permanent magnet, and is the magnetic remanence of the magnet. To make this integral more tractable, we can assume that the magnets are “thin” magnets and thus set , giving us the slightly “simpler” integral:

Where here we need only integrate over one surface (by symmetry, whether we choose this to be the front or back of the magnet doesn’t matter) as opposed to the six integrals that would otherwise need to be done for . Thus the surface integral reduces to the following double integral:

To solve this integral, we first integrate with respect to with the following substitution:

Now we may use the following identity:

Which allows us to evaluate the integral in as follows:

Now, substituting in the explicit form of , we have:

With the substitution we obtain the two integrals in a slightly simpler form:

Both of the resulting integrals in the sum are integrals of the form:

This is an integral that can be evaluated using integration by parts or (more conveniently) by consulting a computer algebra system; the solution is given (up to a constant) by2:

Where we will not write out explicitly in the rest of the solution for simplicity. Thus we have:

Where we define as:

And thus the complete solution can then be written succinctly as:

While appearing deceptively-simple, this succinct answer expands out to 12 terms(!) in total, making it highly impractical to use for actually compute this solution. A much more numerically-usable solution can be found by not evaluating the integral in , giving us:

Where the function (here ) is defined by the following integral:

And thus the magnetic field can be found (via ) to be:

The numerical derivatives here can be found by finite differences, but the analytical derivative can also be found by differentiating under the integral sign; that is:

Note that for small , while for very large . If we consider the magnetic field far away from the magnet, then becomes very small; hence we can apply the small approximation, giving us:

Substituting this result into our analytical expression for gives us:

However, since we assume is large, thus and . Thus the above result becomes:

Hence, we see that the magnetic scalar potential (and thus magnetic field) of a permanent magnet drops off extremely rapidly to zero at large distances. This is why a fridge magnet is not dangerous, even though the magnetic remanence of its material may be quite high. A different scenario emerges, however, when we consider the magnetic field close to the surface of the magnet, that is, for small . In this case, we use the large approximation of , giving us:

This integral is straightforward to evaluate, and gives:

Therefore, the magnetic scalar potential is given by:

From which we may find to be:

It is useful to note that this contains a term that can be expanded as a geometric series:

Hence, assuming that then one has:

Hence the magnetic field generally satisfies an inverse-square law at short distances and can be incredibly strong near the surface of a permanent magnet.

Solving with a CAS

In theory, the surface integral can also be evaluated with the following Mathematica code:

yprime = Subscript[p, y]
zprime = Subscript[p, z]
Integrate[
	 1/Sqrt[x^2 + (y - yprime)^2 + (z - zprime)^2],
	 {yprime, 0, L}, {zprime, 0, w}
 ]

Or with the following SymPy code:

from sympy import *
x, y, z = symbols("x y z", real=True)
Br, w, L = symbols("B_r w L", constant=True, 
		real=True, positive=True)
mu0 = Symbol(r"\mu_0")
yprime, zprime = symbols("y' z'")
prefactor = Br/(2*pi*mu0)
integrand = 1/sqrt(x**2 + (y-yprime)**2 + (z - zprime)**2)
integral = Integral(integrand, (yprime, 0, L), (zprime, 0, w))
psi = prefactor * integral.doit()
Eq(Symbol(r"\psi_m"), psi)

However, both SymPy and Mathematica time out when trying to compute the integral; it is likely that neither can compute it, even if they are given longer times, due to the complexity of the integral.

Far field of a block magnet

In the far field (), a block magnet is much easier to model, as its geometric features are negligible in the far-field. A block magnet in the far field closely resembles a magnetic dipole, whose field roughly follows an inverse-cube law:

We can derive this in a straightforward way. To start, the magnetic field of a single magnet with constant magnetization could be approximated as a perfect dipole at distances “far” from the magnet, which has a magnetic field given by:

The term drops off rapidly with distance, and hence it has negligible effect at long distances. This leaves us with:

Therefore, the far-field of a block magnet follows an inverse-cubic decay, resulting in a field that rapidly decays to zero. The magnet thus only has a noticeable magnetic effect at short distances, where its field is at its greatest strength.

Consistency checks for calculated fields

To check that our solutions are indeed physically-valid, we must substitute them into Maxwell’s equations: specifically, Gauss’s law () and Ampere’s law (). This calculation is incomplete at time of writing.

Basic experiment using a simple compass magnet

Note: The mathematics of the experiment described here are incorrect and should be updated, since a dipole field is assumed despite that only being applicable in the far-field.

A rudimentary way to test the correctness of the theoretical formulas experimentally is with a simple toy experiment. Place a small compass needle near a pair of alternating neodynium magnets. Here is the magnetic moment of the test (compass-style) magnet, which has a magnetic remanence approximately that of Earth’s magnetic field (, where ). Thus its magnetic moment magnitude is:

Where is the compass needle volume. Meanwhile, is the ambient field generated by the primary magnet. We assume that the test magnet does not disturb the field to a great degree. The magnetic field of each magnet would have the following magnitude, as per our calculations:

We would expect the magnetic field to vary sinusoidally along the alternating magnets, but as a first approximation, we can assume the magnetic field to vary linearly along the axis between them. Thus, the field in between the two magnets is then:

The magnitude of the force on the compass needle due to the ambient field is given by:

Assuming small oscillations, we can model this as simple harmonic oscillator, where , where is the length of the test magnet needle and is its mass. Therefore, we have:

Note: It should be pretty evident that this can yield at most an order-of-magnitude agreement with theory. An EMF meter and a much more sensitive experiment would be necessary for anything more precise.

Footnotes

  1. See Jackson, Classical Electrodynamics (3rd. ed.), pg. 207, eq. 5.100. ↩

  2. This was obtained using MathDF but can also be found using a dedicated computer algebra system. ↩