Yang–Mills and the mass gap explained for programmers

Yang–Mills and the mass gap explained for programmers
$1,000,000prize from the Clay Institute, offered in 2000
1954Yang and Mills publish their theory
~1%of the proton's mass is the mass of its three quarks
Δ > 0the mass gap: still unproven
Yang–Mills and the Mass Gap: the million-dollar problem, explained for programmers
I also explain it in this video, on my channel Articulator EN. The grid you see in the video and in this post is a real (toy) simulation, written in Python.

Four forces and a fieldlink

There are four forces in the universe: gravity, electromagnetism and two that only act inside the atom, the weak and the strong force. The strong force holds the nucleus together: it's so intense that it beats the repulsion between protons, which push each other away because they're all positively charged. And yet its range is tiny: outside the nucleus, it vanishes. Keep that detail in mind, because it's the key to this whole post.

To a physicist, a force is a field. And to a programmer, a field is easy to picture: a function that assigns a value to every point in space. Like a shader, which assigns a color to every pixel, or like a giant array with one entry per point. The electric field stores an arrow at every point: the direction it would push a charge you placed there. The waves of that field are light.

Now the quantum part: the waves of a field can't carry just any energy, they come in packets, as if energy had pixels. The smallest packet of light is the photon, and the photon has no mass. That's why you can create photons with as little energy as you like (radio waves are photons with very little energy), and that's why electromagnetism reaches so far: light from a star crosses the universe to reach your eyes.

Yang and Mills' idealink

The key idea is gauge symmetry. Think about time zones: if we all store dates in UTC, or all in Madrid time, the world works the same, because what matters are the differences. That freedom to pick the origin without changing anything is a symmetry. Now imagine something crazier: every city picks its own clock, without telling anyone. To compare clocks between two neighboring cities you need a conversion table.

That conversion table is exactly the field. In electromagnetism, each point's convention is an angle, like the hand of a clock, and the table says how much to rotate when you step from a point to its neighbor. The beautiful part: if you demand that physics doesn't depend on each point's convention, Maxwell's equations fall right out. The force appears as the price of that freedom.

In 1954, Chen Ning Yang and Robert Mills asked: what if the convention wasn't an angle, but a matrix? Instead of a clock hand turning in a plane, an orientation in several dimensions. It looks like a small change, but with matrices order matters: A @ B != B @ A.

A phone rotated in two different orders ends up in two different positions
Rotations in three dimensions don't commute: the order changes the result.

Check it with your phone: tilt it ninety degrees forward, then turn it to the side; start again and do the two turns in the opposite order. It ends up in a different position. And that changes everything: in Yang–Mills theory, the particles of the field carry charge themselves. Photons ignore each other (two flashlight beams cross without colliding), but these particles attract each other, and the equation stops being linear.

There was a problem. Yang and Mills' equations, just like those of light, describe massless particles, and massless particles mean a long-range force. But nuclear forces have a tiny range. Wolfgang Pauli confronted Yang about it in the middle of a seminar: what about the mass of these particles? Yang had no answer, and for years the theory looked like a beautiful idea that was simply wrong.

The strong forcelink

The answer came in the seventies. Protons and neutrons are made of quarks, three each, and quarks carry a kind of charge that physicists called color, with three values: red, green and blue. It isn't real color, it's just a name, but your programmer intuition works: like in RGB, all three together make white, and a proton is white (neutral) because it combines all three.

The particle that glues quarks together is the gluon, and the theory that describes them, quantum chromodynamics, is a Yang–Mills theory with three by three matrices: the group SU(3). There are eight gluons and, as the theory demands, they carry color, so they stick to each other. Inside, a proton isn't three little balls sitting still: it's a boiling soup of quarks and gluons popping in and out.

  • Confinement. Nobody has ever seen a free quark. If you try to pull two apart, the force doesn't weaken with distance the way magnets do: it stays constant, like a rubber band that never stops pulling. The more you stretch it, the more energy it stores, until there's so much that it turns into matter: a new quark–antiquark pair appears, the band snaps into two bands, and once again you have no lone quark.
  • Asymptotic freedom. Up close the opposite happens: when quarks are very close together they barely feel each other. It was discovered by Gross, Wilczek and Politzer in 1973 (Nobel Prize 2004). It's a force that's weak up close and incredibly strong far away. The close-up part can be computed with pencil and paper; the far part can't.

And the fact from the start: a proton weighs as much as about 1,800 electrons, but if you add up the masses of its three quarks you get around 1%. The other 99% is energy: quarks moving at tremendous speed and the gluon field that traps them. Energy and mass are the same thing (E = mc²), so almost all of your body's mass is the energy of a Yang–Mills field.

Bars: the mass of the three quarks is about 1% of the proton's mass; the rest, about 99%, is energy
Quark masses versus the energy of quarks and gluons, in the proton (approximate values).

The million dollar problemlink

In 2000, the Clay Mathematics Institute picked seven problems and offered a million dollars for each. Only one has been solved, the Poincaré conjecture. The Yang–Mills problem was written by Arthur Jaffe and Edward Witten, and it asks for two things, for any compact simple gauge group (like SU(3)):

1 · Existence

Prove that quantum Yang–Mills theory truly exists, as a mathematical object, in our four-dimensional spacetime.

2 · Mass gap

Prove that the lowest energy above the vacuum is strictly greater than zero: Δ > 0.

What do you mean, prove it exists, if physicists use it every day? Think of a program that gives correct results but whose code relies on undefined behavior: it works on your machine, and nobody has proven it's well defined. Quantum field theory is like that: it predicts experiments with brutal precision, but along the way infinities show up and get removed with recipes. What's missing is a clean mathematical construction.

That's why the problem comes with a specification, like an API contract: the theory must satisfy a set of axioms (Wightman's, or Osterwalder and Schrader's). They're rules like energy is never negative, nothing travels faster than light, and results don't depend on how you're moving. It's a test suite: you have to build a theory that passes all of them and that, at short distances, behaves the way physicists say.

The second part, the mass gap, is easiest to picture as an energy store. In electromagnetism you can buy photons as cheap as you like, with no lower limit. In Yang–Mills you can't: there's a minimum price. Between the vacuum, which costs nothing, and the lightest thing you can create, there's a jump.

Two energy spectra: photons go all the way down to zero; in Yang–Mills there is a gap between the vacuum and the first state, a glueball of about 1.7 GeV
Without a gap, states as cheap as you like; with a gap, a minimum price Δ.

Why does that jump matter? Because it explains the mystery from the start: if the cheapest thing the field can carry has mass, the field dies off exponentially with distance. With no gap, the force would reach far, like light; with a gap, it stays within tiny distances. And the strangest part: there's no mass anywhere in the classical equations, classical Yang–Mills waves travel at the speed of light. The mass shows up when you make it quantum, seemingly out of nothing.

In a world with only gluons and no quarks, the lightest thing you could create would be a ball of gluons stuck to each other: a glueball. Nobody has isolated one with certainty in an experiment, because in the real world it mixes with quarks, but lattice calculations put it at around 1.7 GeV, almost two protons. That number, greater than zero, is the gap. Physicists can see it. Mathematicians can't prove it.

Why it is so hardlink

  • The size. A field has a value at every point, and space is continuous: an array with infinitely many entries. In the quantum version there isn't just one state of the field, but a sum over all possible states at once, each with its own weight. It's as if, to compute anything, you had to loop over every possible image at infinite resolution. No loop like that ever finishes.
  • The infinities. You get sums that don't converge, because the field can vibrate at smaller and smaller scales. Renormalization cuts off the tiny scales, tunes the parameters and checks that the result doesn't depend on the cutoff. It works wonderfully, and in the seventies it was proven that it always works for Yang–Mills. But those are rules for calculating, not a construction.
  • Approximation is blind. The physicist's favorite tool is adding small corrections to an easy case, like a Taylor series. But the gap depends on the strength of the force like this function: exp(-1/x**2).
The function e to the minus one over x squared, flat at zero, next to its Taylor series at zero, which is identically zero
At zero it's zero and so are all its derivatives: to the Taylor series it's the zero function, but it isn't.

Near zero, any finite number of corrections gives exactly zero. It's like a test that always passes because it never enters the branch where the bug lives. To see the gap, you have to understand the regime where the force is strong, and there are no small corrections to add up there.

The universe on a gridlink

In 1974, Kenneth Wilson had the idea any programmer would have: discretize. He replaced continuous spacetime with a grid of points, like pixels. On every edge between two points you store a matrix, the conversion table from before. And you measure the field on every little square: if you go around it multiplying its four matrices and don't get back to the identity, there's a field there.

A grid with an SU(2) matrix on every edge and every little square colored by its energy
A frame from our toy simulation: SU(2) in two dimensions.

With the grid, infinity becomes finite and you can simulate it: you generate thousands of field configurations with the Monte Carlo method (weighted random sampling) and average. That's how supercomputers have calculated the proton's mass with errors of a few percent, seen confinement and measured the glueball.

Average Wilson loop versus loop area on a log scale: the simulation points follow the line of the exact formula
In the toy simulation, the Wilson loop falls with the area, just like the exact 2D formula (the last point is already statistical noise).

But a simulation is not a proof. The grid has a finite size and a spacing between points, and the real theory is the limit: points infinitely close together and infinite space. It's like rendering in Full HD, 4K and 8K and watching the image settle down. The problem asks you to prove that the infinite resolution image exists and that in it the gap is still greater than zero: that it doesn't close as you refine.

And here's the catch. On the grid, with a very strong force, it has been proven that there is a gap: Osterwalder and Seiler did it in 1978. But to reach the continuum you have to bring the points closer, and as you do, the force becomes weak because of asymptotic freedom. What's been proven holds where it's easy; what's needed is exactly the bridge between the two extremes.

What we already knowlink

  • In two dimensions, Yang–Mills is solved: it's simple enough that almost everything can be calculated exactly. Our toy simulation matches that formula.
  • Tadeusz Balaban, in the eighties, proved huge pieces of the step from the grid to the continuum, scale by scale, in a finite volume.
  • Glimm and Jaffe (the same Jaffe who wrote the problem) rigorously built simpler quantum field theories in the seventies, in two and three dimensions. In four dimensions, ours, nobody had rigorously built a single interacting theory. Not one.

The full problem, in four dimensions and in all of space, remained open. Until this fall, at least for its first half.

Fall 2026link

OpenAI · October 26

According to its announcement, its models produced an existence proof for certain quantum field theories with gauge fields and fermions in four dimensions, with pure Yang–Mills as part of the problem. They wrote it in natural language in September and finished formalizing it in Lean (a language that checks proofs the way a compiler checks code) on October 16. They don't mention the mass gap.

The committee · November 9

A group led by David Gross (with Michael Douglas, Arthur Jaffe, Igor Klebanov and Nikita Nekrasov) concluded, according to Scientific American, that the result proves the existence of pure Yang–Mills according to the problem statements. But they wrote that they don't fully understand the proof yet, and that the mass gap remains unresolved.

And there is pushback: the materials weren't released openly from the start, and mathematicians like Peter Woit dispute that this kind of "existence" is what the problem asks for.

Where things stand, cautiously

Existence has a strong candidate, waiting for open review. The mass gap remains unproven, and neither OpenAI nor the committee claims to have proven it. On the Clay Institute's website, the problem is still marked unsolved.

Why should you care?link

First, because it's you: almost all of your mass comes from this mechanism that nobody has proven. Second, because of the method: modern physics runs on theories that give perfect results, but whose mathematical source code never fully compiled. And third, because the tools attacking it are your tools: simulation, formal verification and, now, agents too.

Try it yourselflink

A toy grid simulation fits in about forty lines of Python with NumPy. Each SU(2) matrix is stored as a unit quaternion (four numbers); the Monte Carlo loop proposes small rotations on the edges and accepts or rejects them based on the energy of the little squares they touch. At the end it compares the average energy with the exact two-dimensional formula:

# Toy SU(2) Yang-Mills on a 2D grid (Wilson + Metropolis)
import numpy as np
from scipy.special import iv

L, beta, rng = 16, 2.2, np.random.default_rng(0)

def mul(a, b):  # quaternion product = SU(2) matrices
    a0, a1, a2, a3 = np.moveaxis(a, -1, 0)
    b0, b1, b2, b3 = np.moveaxis(b, -1, 0)
    return np.stack([a0*b0 - a1*b1 - a2*b2 - a3*b3,
                     a0*b1 + a1*b0 + a2*b3 - a3*b2,
                     a0*b2 - a1*b3 + a2*b0 + a3*b1,
                     a0*b3 + a1*b2 - a2*b1 + a3*b0], -1)

dag = lambda a: a * [1, -1, -1, -1]          # inverse (conjugate)
unit = lambda q: q / np.linalg.norm(q, axis=-1, keepdims=True)

def plaquette(U):  # around the little square: Ux · Uy · Ux† · Uy†
    ux, uy = U[:, :, 0], U[:, :, 1]
    return mul(mul(mul(ux, np.roll(uy, -1, 1)), dag(np.roll(ux, -1, 0))), dag(uy))[..., 0]

def energy_near(U, mu):  # the two plaquettes touching each link
    P = plaquette(U)
    return P + np.roll(P, 1, 0 if mu == 0 else 1)

U = unit(rng.normal(size=(L, L, 2, 4)))        # random matrices on every edge
yy, xx = np.mgrid[0:L, 0:L]
meas = []
for sweep in range(300):                        # Monte Carlo loop
    for mu in (0, 1):
        for par in (0, 1):
            sel = ((yy if mu == 0 else xx) % 2) == par
            kick = unit(np.concatenate([np.ones((L, L, 1)), 0.5 * rng.normal(size=(L, L, 3))], -1))
            new = U.copy()
            new[:, :, mu] = np.where(sel[..., None], mul(kick, U[:, :, mu]), U[:, :, mu])
            dS = beta * (energy_near(new, mu) - energy_near(U, mu))
            ok = sel & (rng.random((L, L)) < np.exp(np.minimum(0, dS)))  # accept or reject
            U[:, :, mu] = np.where(ok[..., None], new[:, :, mu], U[:, :, mu])
    if sweep >= 100:
        meas.append(plaquette(U).mean())          # medida

print("simulation :", np.mean(meas).round(3))
print("2D formula :", (iv(2, beta) / iv(1, beta)).round(3))

The two numbers come out almost the same. You won't win the million, but you'll see with your own eyes how we calculate the physics that holds your atoms together. Try changing beta: the bigger it is, the weaker the force and the closer the little squares get to the identity.

In shortlink

Yang–Mills theory describes the force that glues quarks together and gives you almost all of your mass. Physicists calculate it, simulate it and measure it, but nobody has proven it has a mass gap, and its existence is still under review.

In one sentence

Supercomputers calculate how much you weigh; why it has to be that way, nobody has proven yet.

Do you think the gap will be proven by a person or by a machine?

Sourceslink

Continue reading

Last posts -->

Have you seen these projects?

Gymnasia

Gymnasia Gymnasia
Expo
React Native
TypeScript
OpenAI
Anthropic

Fitness app with two agents that run entirely on the device, with no backend, so the user's data never leaves the phone. A BYOK conversational coach with local tools and a remote system prompt with offline fallback, plus a food estimator that pulls macronutrients out of a photo of the plate, with barcode scanning against OpenFoodFacts.

LangGraph Deep Researcher

LangGraph Deep Researcher LangGraph Deep Researcher
Python
LangGraph
FastAPI
React
TypeScript
Docker

Multi-agent research system built with LangGraph. A supervisor breaks your question down into topics and launches search sub-agents in parallel; each one compresses its findings before handing them to a writer agent that produces the final sourced markdown report. Live streaming over WebSockets, a configurable model per role and bring-your-own API keys that are never persisted server-side.

Tau

Tau Tau
Python
LangChain

Multi-agent tutoring system for secondary school students, with one agent per subject and course material written and validated by a team of teachers. It was used with real students at a private school in Spain and at a secondary school in Colombia.

View all projects -->
>_ Available for projects

Do you have an AI project?

Let's talk.

maximofn@gmail.com

Machine Learning and AI specialist. I develop solutions with generative AI, intelligent agents and custom models.

Do you want to watch any talk?

Last talks -->

Do you want to improve with these tips?

Last tips -->

Use this locally

Hugging Face spaces allow us to run models with very simple demos, but what if the demo breaks? Or if the user deletes it? That's why I've created docker containers with some interesting spaces, to be able to use them locally, whatever happens. In fact, if you click on any project view button, it may take you to a space that doesn't work.

Flow edit

Flow edit Flow edit

FLUX.1-RealismLora

FLUX.1-RealismLora FLUX.1-RealismLora
View all containers -->
>_ Available for projects

Do you have an AI project?

Let's talk.

maximofn@gmail.com

Machine Learning and AI specialist. I develop solutions with generative AI, intelligent agents and custom models.

Do you want to train your model with these datasets?

short-jokes-dataset

HuggingFace

Dataset with jokes in English

Use: Fine-tuning text generation models for humor

231K rows 2 columns 45 MB
View on HuggingFace →

opus100

HuggingFace

Dataset with translations from English to Spanish

Use: Training English-Spanish translation models

1M rows 2 columns 210 MB
View on HuggingFace →

netflix_titles

HuggingFace

Dataset with Netflix movies and series

Use: Netflix catalog analysis and recommendation systems

8.8K rows 12 columns 3.5 MB
View on HuggingFace →
View more datasets -->