EMDyna Sandbox Scene Details
Overview Manual & Theory Validation Suite Python API Gallery Open Simulator

← Back to Scene Gallery

OfficialEasyLevitating a magnet with magnets

The lower magnet is fixed and the upper magnet can move only up and down. Like poles face each other, so they repel, and the upper magnet floats at the height where this balances gravity (the yellow arrow is the force acting on the magnet). Select the upper magnet and set translation and rotation to "Free" in "Mechanics", and it flips over and the magnets attract. This shows that magnets alone cannot levitate stably.

Oct 8, 2026 • 5 views

Launch & Remix in Simulator

Read the explanation, with equations and figures ↓

Modify this scene in the simulator, then open the "Scene" tab and click "Publish Current Scene to Gallery" to share your remix!

·

In short

Two magnets push against each other when their matching poles face. The top magnet floats above the bottom one because magnetic repulsion pushes up with the same force that gravity pulls down.

This rule is Earnshaw's theorem: permanent magnets alone cannot float stably in mid-air in all directions.

What you are looking at

Magnetic repulsion between two permanent magnets and the demonstration of Earnshaw's theorem:

  • Bottom magnet: A cylindrical permanent neodymium magnet (Br=1.2ย TB_r = 1.2\text{ T}, radius 1.2ย cm1.2\text{ cm}) fixed rigidly to the ground.
  • Top magnet: An identical permanent magnet placed directly above it, with like magnetic poles facing each other (North-to-North or South-to-South).
  • Constrained strictly along the vertical yy-axis, the top magnet bounces momentarily before settling into stable mid-air levitation above the bottom magnet. Yellow vectors depict the real-time magnetic forces acting on the magnets.

However, if you release the mechanical constraints and allow the top magnet to move and rotate freely in 3D space, it instantly flips upside-down, attracts the bottom magnet, and slams into it.

Magnetic dipole repulsion vs. gravity

Two coaxial magnetic dipoles m1\mathbf{m}_1 and m2\mathbf{m}_2 oriented antiparallel along the vertical axis experience a repulsive magnetic force:

Fmag(y)โ‰ˆ3ฮผ0m1m22ฯ€y4F_{\text{mag}}(y) \approx \frac{3\mu_0 m_1 m_2}{2\pi y^4}

where yy is the center-to-center vertical separation.

The downward force of gravity acting on the upper magnet of mass MM is:

Fg=MgF_g = Mg

At the vertical equilibrium height yeqy_{\text{eq}}, the upward magnetic repulsion exactly matches the downward gravitational weight:

Fmag(yeq)=Mgโ€…โ€ŠโŸนโ€…โ€Šyeqโ‰ˆ(3ฮผ0m1m22ฯ€Mg)1/4F_{\text{mag}}(y_{\text{eq}}) = Mg \implies y_{\text{eq}} \approx \left(\frac{3\mu_0 m_1 m_2}{2\pi M g}\right)^{1/4}

Along the vertical axis, this equilibrium is restoring (stable against vertical displacement):

  • If the magnet is pushed downward (y<yeqy < y_{\text{eq}}), the rapid 1/y41/y^4 surge in magnetic repulsion pushes it back up.
  • If pulled upward (y>yeqy > y_{\text{eq}}), gravity exceeds repulsion and pulls it back down.
โˆ‚Fyโˆ‚y<0(verticallyย stable)\frac{\partial F_y}{\partial y} < 0 \quad (\text{vertically stable})

Earnshaw's theorem and 3D instability

While vertical motion can easily be stabilized, Earnshaw's theorem (proven by Samuel Earnshaw in 1842) establishes that:

Why static magnetic levitation is inherently unstable in 3D

In magnetostatics without free currents:

โˆ‡โ‹…B=0andโˆ‡ร—B=0โ€…โ€ŠโŸนโ€…โ€Šโˆ‡2ฮฆM=0\nabla \cdot \mathbf{B} = 0 \quad \text{and} \quad \nabla \times \mathbf{B} = 0 \implies \nabla^2 \Phi_M = 0

The magnetic potential energy U=โˆ’mโ‹…BU = -\mathbf{m} \cdot \mathbf{B} satisfies Laplace's equation:

โˆ‡2U=โˆ‚2Uโˆ‚x2+โˆ‚2Uโˆ‚y2+โˆ‚2Uโˆ‚z2=0\nabla^2 U = \frac{\partial^2 U}{\partial x^2} + \frac{\partial^2 U}{\partial y^2} + \frac{\partial^2 U}{\partial z^2} = 0

For an equilibrium point to be truly stable in all three spatial dimensions, all second spatial derivatives must be strictly positive: โˆ‚2Uโˆ‚x2>0\frac{\partial^2 U}{\partial x^2} > 0, โˆ‚2Uโˆ‚y2>0\frac{\partial^2 U}{\partial y^2} > 0, and โˆ‚2Uโˆ‚z2>0\frac{\partial^2 U}{\partial z^2} > 0.

However, because their sum must equal zero (โˆ‡2U=0\nabla^2 U = 0), it is mathematically impossible for all three eigenvalues to be positive simultaneously:

  • If the vertical axis is made stable (โˆ‚2Uโˆ‚y2>0\frac{\partial^2 U}{\partial y^2} > 0), at least one horizontal direction must be unstable:
โˆ‚2Uโˆ‚x2+โˆ‚2Uโˆ‚z2=โˆ’โˆ‚2Uโˆ‚y2<0\frac{\partial^2 U}{\partial x^2} + \frac{\partial^2 U}{\partial z^2} = -\frac{\partial^2 U}{\partial y^2} < 0

Any horizontal displacement creates an outward force that pushes the magnet sideways off its cushion. Furthermore, the torque T=mร—B\mathbf{T} = \mathbf{m} \times \mathbf{B} creates a rotational instability that causes the upper magnet to flip 180โˆ˜180^\circ into an attracting configuration.

Motion modeMechanical constraintStabilityPhysical outcome
Guided (1D)Constrained to vertical axis (yy)StableFloats in equilibrium at yeqy_{\text{eq}}
Free (3D)Unconstrained translation and rotationUnstableFlips over and snaps onto bottom magnet

Overcoming Earnshaw's theorem in engineering

To achieve true, unconstrained 3D levitation, practical systems must bypass the assumptions of Earnshaw's theorem:

  1. Dynamic active feedback: Electromagnetic suspension (EMS) using fast optical sensors and electromagnets.
  2. Diamagnetism and Superconductivity: Diamagnetic materials (ฮผr<1\mu_r < 1) and superconductors (Meissner effect and flux pinning) whose magnetization M\mathbf{M} is not fixed, but opposes the local field.
  3. Rotation (Spin-stabilized levitation): The Levitron magnetic top, where gyroscopic precession counteracts the flipping torque.

Try it

Comments