Deriving magnetism from electrostatics and relativity

Imagine a world where there was no magnetism at all — just electrostatic forces. It turns out that by adding Einstein’s laws of special relativity to that world, and looking at the effects that special relativity has on moving charges, the laws of magnetism appear — just by mashing electrostatics and relativity together.

In other words, the moving electrons in an electric motor’s coils see the world from a different frame of reference to the copper atoms making up the windings of the motor — and this imbalance is what makes the motor turn!

There’s a bunch of stuff around on the internet on this, but I find it hard to process because it deals with general relationships between magnetic and electric fields, not specific examples. I’m sure this is actually very general and useful, but it’s also beyond my immediate understanding as well. So, I tried approach the problem in my own way using just special relativity and high-school level physics, and it works!

0. Ampère’s force law: the result we are trying to arrive at

We’re aiming for the most basic formulation of Ampère’s force law, which gives the magnetic force between two parallel wires:

\displaystyle F = \frac{\mu_0 I_1 I_2 \ell}{2 \pi y}

Where \mu_0 is the magnetic constant, I_1 and I_2 are the currents through the two wires, \ell is the length of the wires, and y is the distance between the two wires.

It’s worth noting that the formula above only holds true when the first wire is of length \ell, and the second wire is of infinite length. This is convenient, because infinite integrals have a tendency to work out more nicely anyway.

(This same equation is often used to calculate the force between two wires both of length \ell, but this is only accurate when \ell is much greater than y.)

1. Our first axiom: Coulomb’s law

The force on a point with charge q_1 due to another point with charge q_2 in a vacuum is given by Coulomb’s law:

\displaystyle F_{1} = \frac{-q_1 q_2}{4 \pi \varepsilon_0 r^2}

where \varepsilon_0 is the electric constant, and r is the distance between the two points. This force is an attraction if positive, a repulsion if negative. If we move over to Cartesian coordinates by substituting \displaystyle r^2=x^2+y^2 , the vertical component of the force is given by

\displaystyle F_{1y} = \frac{y}{\sqrt{x^2+y^2}} \frac{-q_1 q_2}{4 \pi \varepsilon_0 (x^2+y^2)}

This term represents the vertical force between an electron or proton in the top wire and an electron or proton in the bottom wire. We could figure out the horizontal component F_x as well, but it would get cancelled out in the end.

2. Electrostatic attractions with charges distributed along lines

Next, we need to take charge q_2 and replace it with an infinite, evenly distributed horizontal line of charge. Each unit length of the line has charge k_2. We’ll call this force F_{2y}. This represents the force between an electron or proton in the top wire, and all of the electrons or all of the protons in the bottom wire. The term inside the integral is the same as F_{1y} above, but with the bottom point charge q_2 replaced by the charge on a infinitesimal length of the line of charge: k_2 \mathrm{d}x.

\begin{array}{rcl}  F_{2y} & = & \displaystyle \int_{-\infty}^{\infty} \frac{y}{\sqrt{x^2+y^2}} \frac{-q_1 k_2 \mathrm{d}x}{4 \pi \varepsilon_0 (x^2+y^2)} \\[20pt]  & = & \displaystyle \frac{-q_1 k_2}{4 \pi \varepsilon_0} \int_{-\infty}^{\infty} \frac{y}{\left(x^2+y^2\right)^{\frac32}} \,\mathrm{d}x \end{array}

This is where the calculus gets fun: this integral looks pretty nasty as it stands. But the hypotenuse-looking term makes it look susceptible to a trigonometric substitution:

\displaystyle x = y \tan \theta \, , \,\,\,\, \frac{\mathrm{d}x}{\mathrm{d}\theta} = \frac{y}{ \cos^2 \theta}

The following identity also comes in handy:

\displaystyle 1 + \tan^2 \theta = \sec^2 \theta = \frac{1}{\cos^2 \theta}

We end up with:

\begin{array}{rcl}  F_{2y} & = & \displaystyle \frac{-q_1 k_2}{4 \pi \varepsilon_0} \int_{-\frac\pi{2}}^{\frac\pi{2}} \frac{y^2}{\cos^2 \theta \left(y^2 \tan^2 \theta +y^2\right)^{\frac32}} \,\mathrm{d}\theta \\[20pt]  & = & \displaystyle \frac{-q_1 k_2}{4 \pi \varepsilon_0} \int_{-\frac\pi{2}}^{\frac\pi{2}} \frac{\cos \theta}{y} \,\mathrm{d}\theta \\[20pt]  & = & \displaystyle \frac{-q_1 k_2}{4 \pi \varepsilon_0 y} \left( \sin \frac\pi{2} - \sin \frac{-\pi}{2} \right) \\[20pt]  & = & \displaystyle \frac{-q_1 k_2}{2 \pi \varepsilon_0 y}  \end{array}

Now we can take the top charge and spread it out along a line as well — although this time, the line is finite in length. This time we substitute q_1 for k_1 \mathrm{d}x. Since the integrand is not a function of x, this integral is trivial:

\displaystyle F_y = \int_{0}^{\ell} \frac{-k_1 k_2}{2 \pi \varepsilon_0 y} \, \mathrm{d}x = \frac{-k_1 k_2 \ell}{2 \pi \varepsilon_0 y}

So, we’re halfway through and we haven’t touched relativity, magnetism, or even motion of any kind yet. But we do have an expression for the electrostatic force between two lines of evenly distributed charge, which we’ll need later.

3. Special relativity: length contraction

Einstein’s theory of special relativity states that when an object is moving, a stationary observer sees some strange effects — a clock on the moving object appears to run slowly (time dilation), and the object appears to be compressed along the direction that it’s travelling (length contraction). Length contraction is described as follows:

\displaystyle L=\frac{L_{0}}{\gamma(v)}

Where L_0 is the length of an object at rest and L is the observed length of the object when moving at velocity v. The Lorentz factor is given by:

\displaystyle \gamma (v) \equiv \frac{1}{\sqrt{1-v^2/c^2}}

So why does length contraction have any relevance to charges moving down a wire? Let’s consider the top wire, which has k_1 Coulombs of charge per unit length. A section of length L_0 will contain a charge L_0 k_1. When current starts flowing, that section of charge will start moving — and will consequently appear to contract according to the formula above. This means the charges will appear to be bunched more closely together, since the same amount of charge is now packed into the contracted length. The new amount of charge per unit length will be:

\displaystyle k'_1 =  \frac{L_0 k_1}{L} = k_1 \gamma(v)

This is the central point of this post — if you start off with a wire that is perfectly neutral (i.e., charges are balanced,) simply allowing current to flow through the wire will cause the electrons to appear to bunch up, while the protons will stay still. This imbalance leads to a net negative charge appearing on the wire! This is all assuming that you’re observing from a stationary frame of reference (with respect to the protons in the wire.) If you move along at the same speed as the electrons, then it’s the protons that will appear to be moving, and bunching up, and you’ll observe a net positive charge on the wire.

We’ll find later that the velocity of charges within a wire is extremely small, so a first-order approximation of the Lorentz factor is acceptable. Since the gradient of 1 / \sqrt{1 - x^2} at x = 0 is \frac12, we can use the following approximation:

\displaystyle \displaystyle \gamma (v) \equiv \frac{1}{\sqrt{1-v^2/c^2}} \simeq 1 + \frac{v^2}{2c^2}

4. Drift velocity of electrons in conductors

In order to calculate the magnitude of the charge contraction, we need to know the velocity of the electrons in the wire. If one unit of wire contains free electrons totalling a charge of k_1, and the velocity of the electrons is v_1, then the total charge moving per unit of time is:

\displaystyle I_1 = k_1 v_1

5. Combining everything together

Let’s now tally up the forces acting on the top wire. First, the protons in the top wire. The protons are at rest, so they see the world from a stationary frame of reference. The protons in the bottom wire are also at rest, so the repulsion force acting on the bottom wire’s protons is not affected by relativity:

 \displaystyle F_{++} =  \frac{-k_1 k_2 \ell}{2 \pi \varepsilon_0 y}

The electrons in the bottom wire are moving though, at a velocity of v_2, so the attraction between the top protons and bottom electrons is given a boost:

 \displaystyle F_{+-} =  \frac{k_1 k_2 \gamma(v_2) \ell}{2 \pi \varepsilon_0 y}

Next, what do the electrons in the top wire see? We’re now travelling along with these electrons, so the protons in the bottom wire appear to be moving backwards at v_1:

 \displaystyle F_{-+} =  \frac{k_1  k_2 \gamma(-v_1)\ell}{2 \pi \varepsilon_0 y}

And the electrons in the bottom wire appear to be moving at a velocity of v_2 - v_1:

 \displaystyle F_{- -} =  \frac{-k_1 k_2 \gamma(v_2-v_1) \ell}{2 \pi \varepsilon_0 y}

The total force acting on the top wire is the sum of these four terms:

\begin{array}{rcl}  F_{\mathrm{total}} & = & \displaystyle \frac{-k_1 k_2 \ell}{2 \pi \varepsilon_0 y} + \frac{k_1 k_2 \gamma(v_2) \ell}{2 \pi \varepsilon_0 y} + \frac{k_1  k_2 \gamma(-v_1)\ell}{2 \pi \varepsilon_0 y} + \frac{-k_1 k_2 \gamma(v_2-v_1) \ell}{2 \pi \varepsilon_0 y} \\[20pt]  & = & \displaystyle \frac{-k_1 k_2 \ell}{2 \pi \varepsilon_0 y} \left( 1 +  \gamma(v_2-v_1) -  \gamma(v_2) -  \gamma(-v_1) \right) \end{array}

Applying the approximation of the Lorentz factor from section 3:

\begin{array}{rcl}  F_{\mathrm{total}} & = & \displaystyle \frac{-k_1 k_2 \ell}{2 \pi \varepsilon_0 y} \left( 1 +  \left( 1 + \frac{(v_2-v_1)^2}{2c^2} \right) - \left(1+ \frac{v_2^2}{2c^2}\right) - \left(1+ \frac{v_1^2}{2c^2}\right) \right) \\[20pt]  & = & \displaystyle \frac{k_1 k_2 \ell}{2 \pi \varepsilon_0 y} \left( \frac{v_1v_2}{c^2} \right) \end{array}

Incorporating the expression for current from section 4:

 \displaystyle  F_{\mathrm{total}} =  \frac{I_1 I_2 \ell}{2 \pi \varepsilon_0 c^2 y}

And applying the definition of the electric constant \displaystyle \varepsilon_0 = \frac1{\mu_0 c^2}:

 \displaystyle  F_{\mathrm{total}} =  \frac{\mu_0 I_1 I_2 \ell}{2 \pi y}

And there you have it — combine electrostatics and special relativity, and you end up with the magnetic formula from section 0.


Although special relativity has been experimentally verified over and over again, it’s often incredibly sensitive instruments (usually atomic clocks) travelling at high speed doing the measuring. Other times, it’s astronomical observations. Even the wonderful point that the GPS system would rapidly fall apart (losing 10 kilometers of accuracy per day) without taking relativity into account seems out of this world (literally). The idea that the relatively familiar force of magnetism is a side effect of relativity seems a lot closer to home.

What’s more amazing is that this happens, despite the incredibly low velocities involved. A length contraction of just 0.1% requires a speed of 13,400,000 m/s. Although electrical signals flow down a wire at very high speed, the charge carriers themselves drift along very slowly — the distinction is much like that between the speed of sound in air vs the speed that the wind blows. A 1 mm diameter copper wire carrying 3 A, has a drift velocity of around 1 metre per hour. At that speed, the Lorentz factor, and the apparent charge imbalance is 1 + 4.3 × 10-25. That’s an excess of 0.000000000000000000000043%. And yet, that’s all you need to give to the electrostatic force for it to drive an electric car around — it just shows how incredibly strong the electrostatic force is.

Take two normal 1mm diameter copper wires 1 meter long, and 1 meter apart. If you were to remove the atoms of copper, leaving just the free electrons behind, the electrostatic repulsion between the two remaining clouds of electrons would be about 1017 kilograms worth — enough to lift a small moon. Somehow, these ridiculously huge and tiny numbers multiply together to give the moderate magnetic force that we use every day.

On the other hand, for a long time, I’ve found both magnetism and special relativity a bit mysterious and strange. It’s somehow comforting to know that one is just a side-effect of the other — one less thing to keep me up at night.

Leave a comment


  1. Excellent article as always!

    A minor grammatical error exists in Section 3: “a stationary observer sees SOME strange effects.”

    Could possibly be worth mentioning the variables in these equations that were set to one to make the maths easier to follow (e.g. charge carrier density, area of conducter, etc) to align them to sites like wikipedia. Would have to be very subtle though.. wouldn’t want such a pedantic point interfering with the main message!

    • Robert

       /  August 10, 2012

      Thank you for the feedback, kind sir. The issue of the variables being set to one is an interesting point — I did spend some time trying to figure out how to use the fact that the only dimension that matters is the dimension of length. So I decided to use a linear charge density (\mathrm{C m}^{-1}), instead of a normal volumetric density (\mathrm{C m}^{-3}), to avoid dealing with the cross-sectional area at all*. But there’s no standard symbol for linear charge density — so yeah, I’m still stuck trying to find an elegant way of presenting this.

      * So technically, it hasn’t been set to 1, it’s been pre-multiplied/divided out.

  2. Jason

     /  August 22, 2012

    What about this?

    Consider two parallel electron beams. Ampere’s Law will still apply. But now there are no protons so the only force will be between the electrons. Your Ftotal will have only one term, the one having (v2-v1)^2.

    Without the other three terms, you won’t get the formula of Ampere’s Law.

    What’s worse is that if the two beams have the same diameter and current, then v2=v1 and therefore Ftotal = 0!

    Sorry if this keeps you up at night again. But don’t despair, it is not easy to derive Ampere’s Law. You may have to resort to Maxwell’s equations. And even that does not make it any easier.

    BTW, since you are interested in these stuff, you may want to check out It has heaps of video lectures on science, math, engineering, history, philosophy, business, etc.

    • Robert

       /  August 23, 2012

      An interesting question, thanks for raising it!

      Does Ampere’s law still apply in that case? If you’ve got v_1=v_2, then all of the electrons are travelling along at this one velocity. I therefore choose to apply Ampere’s law in the frame of reference of an electron in the beam. Now v_1=v_2=0, so the magnetic force equals zero. This means that applying Ampere’s law to beams of electrons in the absence balancing positive charges leads immediately to a contradiction, so Ampere’s law does not apply.

      Furthermore, the single F_{\mathrm{total}} term for the electron/electron interactions is proportional to \gamma(v_2-v_1) \simeq 1 + \frac{(v_2-v_1)^2}{2c^2}, or, when v_1=v_2, just 1. So it just gives a plain, unadjusted term for electrostatic interaction between all the electrons — which seems exactly right to me?

      (It’s getting late here, I will tidy up and clarify this reply in due course.)

      • Jason

         /  August 23, 2012

        Sorry, I think I confused you in my (erroneous) assertion about v1=v2.

        When v1=v2 (i.e. same current), Ftotal 0. But it reduces to:
        Ftotal = k1*k2*L / 2*pi*epsilon*y (i.e. no c^2). Ftotal is not zero so Ampere’s Law does apply.
        But without c^2 you won’t be able to bring mu into Ftotal.

        When v1=v2, there is no relativistic effect.
        When v1=v2=0, the current is zero and therefore there is no magnetic field, so the only effect is electrostatic — as you said. (How you get an electronic beam with zero current is another matter which we won’t go into here!)

        It was quite neat the way you used the Lorentz factor to bring c^2 into the picture in the case of the two wires.

        Another oops! The URL I referred to at the end of my last comment is not

  3. Xanthe

     /  December 7, 2015

    I have to confess I don’t quite understand some of the calculus, specifically why the limits change to pi/2 and -pi/2 – I’m sure it’s fairly basic but I haven’t come across something like that before. I’d really appreciate an explanation suitable for a 17 year old if you have time!
    Thanks 🙂

    • Robert

       /  December 7, 2015

      If you look up “integral trig substitution”, you should find a bunch of guides where adjusting the limits is a crucial step.

      Basically, in the before case, the limits being -\infty to \infty actually specifically means that the limits are from x = -\infty to x = \infty, because the integral ends in \mathrm{d}x.

      The goal of the substitution was to write the integral in terms of \theta — so the limits become \theta = -\frac\pi{2} to \theta = \frac\pi{2}. Because, for example, when x = \infty, \theta = \tan^{-1}x = \tan^{-1}{\infty} = \frac\pi{2}.

      Hopefully you can find a reference online about trig substitution that will help that make sense! Please do get back to me if you have more questions.

  4. Xanthe

     /  December 7, 2015

    Really interesting article by the way!

  5. Mark

     /  January 27, 2019


    For me this is the best explanation so far. I was looking for an answer why the force could be so big if the speed of the electrons is so slow.

    The only thing that keeps me up at night, is the protons. In most explanations, this one included, the protons are at rest in the rest frame. Lets stay in the rest frame and connect the wire to a DC source. The electrons start moving. Now, from the rest frame perspective, the chain of electrons should now contract, which would make the net charge negative. This would result in an opposite force than the one in the motion frame. This obviously doesn’t happen.

    The only solution to this problem, as far as i can think of, is that the protons are not relavant, neither are the electrons themselves. It’s the negative charges caused by the electrons flowing one way, and the positive charges caused by the lack of electrons (holes) flowing the opposite way. In the rest frame these would cancel each other out at any current.

    Does anyone know more about this?
    And would the equations above be still valid in that case?

    • Robert

       /  January 27, 2019

      Thanks for the kind comments. I don’t quite follow what you’re referring to your problem, but my best guess is that I handle this in section 5. The \frac{v_1^2}{2c^2} and \frac{v_2^2}{2c^2} end up cancelling out (“opposite forces cancelling out”??), but the central term from expanding \frac{(v_1+v_2)^2}{2c^2}, \frac{v_1 v_2}{2c^2}, doesn’t get cancelled out. This is the term which accounts for the magnetic force, even though it isn’t simply attributable to any particular interaction (electron-electron or proton-electron etc), but only attributable to the term that emerges unscathed after cancelling out all the conflicting terms from adding all four permutations.

  6. Andrzej Rabczenko

     /  October 25, 2019

    Dear Robert, I found your explanation marveless.
    I was looking for it few days, and finally it is.
    I am trying to describe several misterious physical phenomena in easy way for students, without higher mathematics. Is it possible to translate your article to Polish, and use it as enclosure for more interested students?

  7. Andrzej

     /  October 25, 2019

    Another question: If I understood well, when a magnetic needle will follow the speed of electrons along the wires, then when speed will be equal speed of electrons (few cm/s) the magnetis field wil disapear? Did anybody make such simply experiments?

    • Robert

       /  February 23, 2020

      If you move a magnetic needle/compass alongside the wire, then one must consider the change in relative velocity of both of electrons *and* the positively-charged nuclei of the metal wire. As such, matching the compass speed to the speed of electrons will still leave an imbalance due to the motion of the compass relative to the positively-charged nuclei of the metal, and so there will still be a magnetic field. This is why section 5 has those 4 separate terms.


Leave a Reply

Your email address will not be published. Required fields are marked *