In this section I intend to detail the source of magnetic force, particularly as experienced by loops of wire in the form of magnetic dipoles. The intent here is to address ultimately how compass needles turn and how ferromagnets attract each other.

I should start by asking for forgiveness. I’ve recently defended my PhD. While the weight is off now, the experience has hobbled my writing voice. It really should be easier at this point but there’s a hollowness that gnaws at me every time I sit down to write. Please forgive the listless undercurrent I’m trying to shake off. The protracted effort of finishing an advanced degree is not small by itself, but it was combined in this case with the first couple months of my daughter’s life. If you’ve ever tried to finish a PhD and survive the first six weeks of an infant’s life simultaneously, you will perhaps know the scope of this strain. I feel thin. But, I’m surviving. This post has lingered for a few months with me going back and forth trying to find the strength to soldier through.

If you will recall the previous sections I posted, part 1 and part 2, you’ll remember that I’m pursuing the lofty goal of explaining how magnets work. In part 1, I detailed some of the very basic equations for magnetism, including connections from Biot-Savart to Ampere’s Law, producing some of the basic definitions of the magnetic field. In part 2, I tackled the construct of the magnetic dipole in the form of a loop of wire. My ultimate goal is to explain how it is that an object like a compass needle can possess and respond to magnetic fields without anything like a loop of wire present. The goal today is to tackle where magnetic force comes from, that is how an object like a magnetic dipole can be dragged through space or rotated so that it changes its orientation in a magnetic field.

As you may already know, the fundamental equation describing magnetic force is the Lorentz force equation.

Lorentz force

This particular version combines electric force (from the E-field) with magnetic force (from the B-field). In this equation ‘F’ is force, ‘q’ is electric charge, ‘v’ is the velocity of that charge, ‘E’ is the E-field and ‘B’ is the B-field. The electric field part of the equation is not needed and we can focus solely on the magnetic part. Magnetic force is a cross product, signified by the ‘x’, which means that the force of the interaction occurs at right angles to the magnetic field acting on the object and the path that object is traveling. If you stop and think about it, this is kind of weird since it means that an electrically charged object must be moving in order to feel a magnetic force. But magnets appear to feel force even if they aren’t moving, right?

A fundamental part of what makes electronics special is that, while the mass of the circuitry stays firmly fixed in position, the electric charges within the wires are able to move. The electricity inside moves even while the computer sits stupidly on the desk. I know this comes as a surprise to no one, but electricity is definitely a something that moves even though the object it moves through appears to remain stationary.

One typical way to deal with the magnetic part of the Lorentz force equation is to cast it in a form conducive to electric current (defined as ‘moving charge’) rather than to directly consider ‘a charge that is moving.’ To do this, you fragment force as a whole into just a piece of force as exerted on a fragment of the charge present in the electric current.

equation 1 lorentz eqn rejigger

In this recast, the force is considered to be due to that tiny fraction of charge. Velocity opens up into length traveled per time where the length contains the fragment of charge ‘dq’. The differential for time is shifted from the length to the charge, creating a current present within the length, “electric current” being defined as “amount of charge passing a point of measurement during a length of time.” In the final form, the fragment of force is due to a current in a length of wire as crossed into the B-field. You could add up all the lengths of a wire containing the current and find the sum of all magnetic force on that wire. One thing to note is that the sign on the current by convention follows the vector direction associated with the length, where the current is considered to be moving positive charges traveling along the length. The direction on the differential length is residual from the velocity. In reality, for real electric current, the current ‘I’ carries a negative sign for the ‘minus’ value of electric charge, creating a negative sign on the force. Negative current will behave as if it is positive current traveling backward.

From previous work, all the elements now exist for dealing with an electromagnet, where the magnetic field comes from and how force is exerted. As illustrated in the previous post, a magnetic field is a mathematical object which is produced in a region of space around a moving charge. As demonstrated here, a basic force is felt by a moving charge when it passes through a magnetic field. These are empirical observations which can be adjusted to say simply that one moving charge has a way of exerting force on a second moving charge, where the force between them is strictly dependent on their movement. If neither such charge were moving, they would feel no force and, if only one charge or the other was moving, they would also feel no force. The idea of magnetic force is in this way a profoundly alien thing, we can understand it only to be a result of the basic precondition of having electric charges moving with respect to one another.

The savvy, science-literate reader may stop and think hard about this and say “Wait a minute, neutron stars, objects made of material lacking any electric charge, have a very powerful magnetic field.” To this, I would smile and refer you to quantum mechanics. The fact that an electrically uncharged neutron can possess or respond to a magnetic field is one of the pieces of evidence that suggests that the protons and neutrons in atomic nuclei are themselves divisible into smaller objects, quarks. One of the great successes of Quantum Electrodynamics was precision calculation of the gyromagnetic ratio of the electron, connecting the magnetic dipole moment of a stationary electron to that electron’s quantum mechanical spin. Spin can be regarded very simply as true to its name: a motion undertaken by an object that does not shift the location of that object’s center of mass. Therefore, magnetic field resulting from spin is still a product of some sort of motion. I probably will never talk very deeply about the Quantum Electrodynamics because I don’t believe I have a very good understanding of it.

There is also a mathematical trick that one can play using Einstein’s Special Relativity to unify electric force and magnetic force, showing that magnetic field is a frame of reference effect and that electric fields are essentially the same thing as magnetic fields, but I will speak no more of this in the current post.

The bottom line, though, is simply this: magnetic force and field, in terms put forward by the Lorentz force law written above and the Biot Savart Law written previously, are due to the motion of charges as currents, either fractional (quarks) or integer charges (electrons, protons and ions) both. This motion can be either translational, such that the charge moves in some direction, or rotational, such that an apparently stationary charge sits there “spinning” sort of like a top.

How these moving currents exert force can be illustrated using the math derived above. The most basic assembly that usually appears in physics classes is the example of two metal wires, each conducting an electric current.

two wiresIn this image, I’ve sketched the basic situation where two wires exist in a cartesian space. The arrangement is in forced perspective because I felt like trying to be artistic. These wires are parallel to each other and the separation between them is constant everywhere along their lengths. Both wires contain an electric current of positive sign that is moving parallel to the z-direction with both currents moving in the same direction. We will assume for simplicity that the separation is much larger than the cross-sectional width of the wire so that we don’t have to do more math than is necessary… in other words, the current is traveling along a line placed along the center of the wire. Here, both wires will produce magnetic fields and, conversely, the currents inside both wires will feel force exerted on them by the magnetic field produced by the other wire.

Electric currents remain trapped within wires because these objects stay electrically neutral: a moving electron is held from leaving the wire by the force of oppositely charged atoms arranged in the crystal lattice of the wire. Force exerted on the current by the magnetic field is transferred to the mass of the wire by these electrical interactions. In a metal wire, “loose” electrons reside in a quantum mechanical structure called a “conduction band” that only exists within the lattice of the crystalline host. Electrons are able to flow freely within this conduction band and cannot leave unless they have been provided with enough energy to jump out of the crystal, this amount of energy called the work function, as illustrated –for instance– by the photoelectric effect. Even under magnetic force, which is felt by the moving charges within the wire and not directly by the mass of the wire, moving charges don’t suddenly jump out of the stationary wire. Magnetic forces on such a current carrying wire can cause the entire wire to move, where the magnetically responsive current drags the entire mass of the wire with it by electrostatic interactions. If enough energy is supplied to loose charges within the wire bulk, these charges can be forced to jump out of the wire, but they usually won’t since most interactions do not provide them with sufficient energy to exceed the work function. Einstein won his Nobel prize for essentially predicting this in the form of the photoelectric effect.

These details not withstanding, the magnetic field produced by one wire can be calculated using Ampere’s Law generated in the previous post.

Loop integral

This magnetic field is the magnetic field of the wire. The only thing you truly need to know here is that the magnetic field will wrap around the wire in the direction of the arrow in the figure above, assuming that the current with positive sign is coming straight out of the page at you. It is noteworthy that the field strength will tend to fall off something like 1/distance moving away from the wire.

Here is the force on the second wire given the magnetic field (from above) imposed on it from the first wire.

attracting wires

With the currents pointed parallel, the wires will tend to experience forces that are directed inward between them. They will tend to pull together.

Suppose we flip the direction of the current in wire 2…

repelling wires

Here, the situation is reversed. The forces are outward such that the wires tend to repel each other. Consider that I’ve done a very soft calculation to see this: all I did was use the direction of the magnetic field at one wire as generated by the opposite wire, filled in the direction of the current for the relevant wire and worked the cross product in my head. There is a subtlety due to the fact that real currents in real wires have the negative charge of real electrons, but the result doesn’t change: parallel currents going the same direction tend to attract while parallel currents going in opposite directions tend to repel.

With the simple construct of two parallel wires, we have the basic tools necessary to go crazy and build us one of these:


Here, we’ve got two parallel wires with current running in opposite directions where we place a third wire perpendicular, in a current arc, between the two. Here is the arrangement:

railgun diagram

In this case, the Lorentz force on the third wire is directed parallel to the first two wires. If the third wire is just a sliding bridge, the magnetic force will accelerate it parallel to the direction of the first two wires: given very high currents and a long accelerating path, this could produce very high velocities.

The advantage is actually quite remarkable in the case of a railgun. For a conventional gun, the muzzle velocity is limited by the detonation rate of the gunpowder, so that the projectile can’t ever go faster than the explosion of the gunpowder expands. For a railgun, there is no such limit. Further, this suggests some architectural requirements in the railgun: the two rails are parallel to each other and have current running in opposite directions, meaning that the rails of the railgun push outward against each other, so that the railgun wants to explode apart. The barrel of the railgun must therefore be built strongly enough to prevent this explosion from occurring. This device is ridiculously simple, but has been militarily difficult to realize because nobody has had a compact or powerful enough electrical generator to realize velocities higher than gunpowder alone that could be transported with the mechanism.

The railgun is really just a momentary curiosity in this post to show that the basic idea of magnetic force has a tangible realization. The next objective it to pursue the compass needle…

For this, we come back to the notion of a current loop as seen in the magnetic dipole post. To begin with, you could fabricate a simplified version of the current loop by simply expanding the model used for the railgun.

self force of loop

In this construction, the wires are all physically connected to each other with the current of wire 1 spilling into wire 4, then from 4 into 2 and so on, going around. The currents in each wire would therefore all be equal. Further, the magnetic field would also be equal on each wire and pointed upward normal to the plane of the loop –if you look back at the images of the magnetic field produced by a wire loop as in the previous post, you can convince yourself that this is the case. The cross product would therefore cause the force to be pointing outward at every location in the plane of the loop. Since the magnitudes of the forces are all equal and the directions are all in opposition, there would be no net force on the object. This is not to say no force; the forces just all balance. For a current loop, as in the railgun, the self-forces are making the loop want to explode outward. The magnetic field of a loop on itself therefore can’t cause that object to translate, but if you increase the current high enough, the force would exceed the tensile strength of the loop and cause it to explode apart.

As I’ve previously mentioned, the wire loop is an analog to the magnetic dipole. I will once again assert totally without proof that a compass needle is essentially a magnetic dipole and will have the same behaviors as a magnetic dipole. If we learn how a current carrying wire loop moves, we will have shown how a compass needle also moves.

Consider first the wire loop immersed in an external magnetic field. This magnetic field will be at an angle to the loop and will be uniform everywhere, which is to say that the strength of the external field is the same on all parts of the loop. Once again, the loop will carry a circulating current of ‘I’.

Current loop in field at angle

First, we could calculate the net force exerted on this wire loop by the external field. You may have an intuition about it, but I’ll calculate it anyway.

Here, I will set up the Lorentz force so that I can calculate each element of the loop and them sum them up by integral. This will ultimately lead me to finding the net force of a uniform magnetic field on a current loop.

Integrating force on loop p1

This converts the force into a cartesian form that can be calculated in a polar geometry, integrating only over the angle Phi in the x-y plane.

Integrating force on loop p2

After working through the cross product, of which only four terms survive, careful examination of these terms shows that there are only two unique integrals in terms of Phi. When you see which they are, since I’m integrating over the full circle, you should know instantly what will happen…

Integrating force on loop p3

Despite the fact that there’s an angle in this calculation, a uniform magnetic field on a current loop will not cause the loop to translate since there is no net force, meaning that the loop cannot be dragged in any direction.

Even though I explicitly ran the calculation so that the astute observer notes where the structure collapses to zero, a little bit of simple logic should also reveal the truth. For the ring of current, there are always two points along the ring which can be selected which are diametrically opposed: these points always experience the same force, but in opposite directions. Therefore, for any set of two such points selected on the ring, the forces cancel to zero, even though the magnetic field is at an angle to the ring, which covers every location along the ring. This depends on the fact that the magnetic field is everywhere uniform. If the strengths of the B-field had been dependent of Phi in the calculation above, there could have been four unique terms, of which maybe none would have integrated to zero.

I’ve concluded here that the ring cannot be dragged in any direction. Note, I did not say that the ring doesn’t move! A more interesting case is to consider what happens if we look instead for torque on the ring. Remember that torque is the rotational equivalent of force, which can cause an object to turn without actually dragging it in any direction.

For convenience, I will calculate the torque from an origin at the center of the ring. I can place my origin anywhere in space that I like, but I’ll fix it to a location which removes a few mathematical steps. I would also note that the magnetic field and the differential length element for a section of ring also have the same forms that I found for them above.

Integrating torque on loop p1

The vector identity I’ve used here is a very simple one which removes the intricacy of the cross product and leaves me with just a vector dot product. I’ve used the fact that the vector describing the location of the unit length of the ring is perpendicular to that unit length at every location where this calculation would ever be made, so long as I calculate torque from the center of the ring.

I already found ‘B’ and ‘dl’ above, so I just need to find a compatible form for the position vector ‘r.’

Integrating torque on loop p2

With this I can finally put all the elements together and start integrating.

Integrating torque on loop p3

After cleaning up the vectors and performing a bit of algebra to consolidate terms, we see that there are only three integrals sitting inside that mess. I chose the limits of integration because I want to work the integral through 360 degrees of the current loop, so 0 to 2Pi. I will work each in turn, but they are easy integrals.

torq integral 1

The first integral simply goes to zero, meaning that the first term in the torque will die. What about the next integral?

torq integral 2

This integral didn’t die. It gave me a piece of pi. The next integral works in a similar manner.

torq integral 3

So, we substitute these three results into the torque equation.

Integrating torque on loop p4

If you squint at the vector portion of that final result there, you might realize that it looks very much like a cross product.

Integrating torque on loop p5

So, a current loop does experience torque when immersed in a magnetic field. Moreover, the vector quantity in that cross product that I left unpacked should look eerily familiar. You might look back at that previous post I did on the magnetic dipole in order to recognize the magnetic dipole moment.

Integrating torque on loop p6

I have achieved a compact expression that says that the current loop will experience a torque within a magnetic field. If the magnetic field is uniform in strength everywhere over the loop, the loop will not be dragged in any direction, but it can be rotated since it will experience a torque. The nature of this rotation can be predicted from the form of the cross product.


If a plane is formed between the magnetic dipole moment of the loop and the magnetic field, the loop will tend to rotate around an axis perpendicular to that plane. Also, because of the form of the cross product, the torque is maximum if the angle between the dipole and the field is 90 degrees; if the vectors point in the same direction (or in exactly opposite directions), the torque goes to zero given the sine. So, the magnetic dipole will tend to want to oscillate around pointing the same direction as the magnetic field and if the action involves friction –so that energy imparted by work done from the torque can be dispersed– these vectors will tend to point in the same direction.

Does this description remind you of anything?


Image from wikipedia

If the needle of a magnetic compass contains a magnetic dipole that points along the needle’s axis, this equation perfectly describes how that needle behaves.

Magnetic dipoles tend to rotate to point along magnetic fields.

There is a non-trivial provision in this statement. The rotation effect I’ve described will occur if the current or moving charge has a trivially small angular momentum with respect to the total rotational inertia of the rotating object. If the angular momentum is large, something very different will happen: the magnetic dipole moment will actually try to precess around the axis of the magnetic field… that is, it will tend to move more like a gyroscope instead of a compass needle. I won’t back this statement up right now, but I hope instead to write a bit more about NMR, of which the classical view involves magnetic precession (magnetic precession fits into the quantum mechanical view of NMR as well, but the effect is much more difficult to see).

This bit of physics also explains why bar magnets tend to rotate in magnetic fields, which is one of the original objectives of this series of posts. This is how magnets (and I use that in the ICP sense of the word) tend to rotate.

How bar magnets move in a magnetic field can be accessed with just a bit more work.

After having collapsed away the directionality of the vectors to produce a scalar version of magnetic torque that shows only the magnitude of torque (so that you can see the sine in the equation), it’s possible to construct a magnetic energy involving the magnetic dipole moment and the field by simply finding the work performed in rotation. The rotational analog of work is torque imposed over a rotation, yielding another integral.


The potential here is a very special one because it’s also the Hamiltonian for spin in a magnetic field in quantum mechanics. I’ll stop short of jumping into the quantum and simply manipulate classical physics. One thing to note here is that I earlier stated that a magnetic dipole experiences no net force if the magnetic field is uniform. What if the magnetic field is no longer uniform?

This sort of potential depends not only on the angle between the vectors, but on the form of the vectors themselves. One way to return to directional force from a potential is to simply take the (spatial) gradient of the potential: it’s important to note that the vectors above are in a dot product, reducing the combination to a scalar… working the gradient of this dot product goes backward through the calculus which produces work from force, instead producing vectoral force from a scalar potential.

Force on dipole

It’s initially difficult to see what this will do, so I’m going to create a situation of simple constructs to demonstrate it. Suppose we have a magnetic dipole sitting in a magnetic field where the dipole and field are pointing in the same direction. Now, suppose that the intensity of this magnetic field gets weaker in some direction, conveniently along the axis that is shared by both vectors.

force on dipole 2

In this particular case, the magnetic dipole will tend to feel a force, as indicated, running opposite the z-axis. It is literally running toward where the magnetic field gets stronger. Note, if you flip the direction of the magnetic dipole, you also flip the sign on the force, making the dipole want to accelerate toward where the magnetic field is weaker. What is this in terms of “toward” or “away from” when considering a real magnetic dipole? Recall my fancy picture of the dipolar magnetic field from three neighboring dipoles:


Here, the colors show the intensity of the field, with red as strong and blue as weak. The fields are red where the dipoles are located and blue further away, meaning that the intensity of the magnetic fields decrease as you go away from a magnetic dipole. In the demonstration of magnetic force above, if the dipole is oriented so that it is in the same direction as the field, it will want to accelerate toward stronger field…. or toward the source of that field if that field is from another dipole. Conversely, if the dipole is oriented so that it faces where the field gets stronger, it will be pushed toward weaker field. In the case of a dipole pointed parallel to the z-axis and positioned at (0,0), the directions of the field look like this:

magnetic dipole

Where the intensity of the field will decrease going away from the origin. A second dipole positioned at location (0,5) and pointed along the z-axis will want to accelerate toward the origin (be attracted), but if rotated to point -z, it will accelerate away (be repelled).

This actually sums up all the behaviors of the bar magnets. In the case of bar magnets, the ends are assigned polarity as the north and south poles. If the magnets are faced with their north ends pointed at each other, the magnets tend to repel, while north end facing south end, they tend to attract. If two magnets are allowed to accelerate toward each other when the south end is pointed to north end, they impact and stick. Meanwhile if they are positioned to repel, north to north, they tend to accelerate away from one another, unless the orientation of one is bumped, whereby one magnet abruptly rotates around 180 degrees (given the non-zero torque mentioned above), and both magnets attract each other again and may accelerate toward each other to stick.

Wow, huh? That sums up how bar magnets work.

So, why doesn’t a compass needle jump out of your hand and accelerate toward one of the poles of planet Earth? Both are dipoles, right. It’s mainly because the field of the Earth is nearly uniform at the location where the compass needle experiences it and therefore with such small gradient, it can’t pull the compass out of your hand.

One subtlety a physics student may note here is that magnetic fields are universally understood to do no work. But, two magnets accelerating across the table and sticking to each other sounds a lot like work. The force I’ve provided as the source of this work is actually due to a spatial derivative of the magnetic field, a gradient, which turns out to be an electric field of a sort. What? Yeah, I know. Weird, but true.

Keep in mind that I haven’t actually solved the final problem of the original post: all of my magnetic dipoles to this point are generated by electrical currents in wires. I still need to show where the magnetic dipole comes from in a metal like iron since there aren’t any batteries in a bar magnet or a compass needle. This is actually a very hard question that dips directly into quantum mechanics and I will end this post here because quantum is its own arena.

Published by foolish physicist

Low level academic enthralled with learning how things work.

Join the Conversation


  1. Spin can be regarded very simply as true to its name

    Emphasis on the “very.” Have you read Tomonaga’s The Story of Spin? I should really go back to it again. I’m really enjoying working my way through this series of posts, in any event. Thanks for putting in the time and effort.


    1. I haven’t read that. Heard it mentioned, but never read it. I’ll have to take look. Spin is mind bending. I’m happy you’re enjoying this series; it’s been a hard one to write with everything going on.


  2. “This device is ridiculously simple, but has been militarily difficult to realize because nobody has had a compact or powerful enough electrical generator to realize velocities higher than gunpowder alone that could be transported with the mechanism.”

    The USS Zumwalt seems to be the prototype.


Leave a comment

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: