Mathematics · January 2025

The Strange Equality That Proved Fermat's Last Theorem

A complete guide to understanding how two unrelated mathematical objects turned out to be the same thing

In 1637, Pierre de Fermat scribbled a note in the margin of a book. He claimed that the equation xⁿ + yⁿ = zⁿ has no whole number solutions when n is greater than 2. He wrote that he had "discovered a truly marvelous proof of this, which this margin is too narrow to contain."

For 358 years, mathematicians tried to find that proof. The problem became the most famous unsolved puzzle in mathematics. Then in 1995, Andrew Wiles proved it, but through a completely unexpected route: he showed that two seemingly unrelated mathematical objects are secretly the same thing.

This post will walk you through that proof, step by step. No advanced math background required. We'll build everything from scratch.

Prerequisites: The Math You Need

Before we dive in, let's make sure we're on the same page about a few concepts. If you're comfortable with these, skip ahead.

Complex Numbers

You probably know that √(-1) doesn't exist in the real numbers. Mathematicians invented a new number to solve this problem: i, defined so that i² = -1.

A complex number i Complex numbers were invented in the 1500s to solve cubic equations. They turned out to be fundamental to physics, engineering, and pure mathematics. is any number of the form a + bi, where a and b are regular (real) numbers. The "a" part is called the real part, and "b" is the imaginary part.

Examples of Complex Numbers

3 + 2i (real part = 3, imaginary part = 2)

-1 + 4i (real part = -1, imaginary part = 4)

5 (real part = 5, imaginary part = 0, so this is also "real")

7i (real part = 0, imaginary part = 7, called "purely imaginary")

You can visualize complex numbers as points on a 2D plane. The horizontal axis is the real part, the vertical axis is the imaginary part.

The Complex Plane
Real Imaginary -2 -1 0 1 2 3 2i i -i -2i 2 + i -1 + 2i 3 i

What Are Primes?

A prime number i Primes are the "atoms" of numbers. Every whole number can be written as a product of primes in exactly one way (this is called the Fundamental Theorem of Arithmetic). is a whole number greater than 1 that can only be divided evenly by 1 and itself.

Prime Numbers

The first few primes: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, ...

Why 6 is NOT prime: 6 = 2 × 3 (it has factors other than 1 and itself)

Why 7 IS prime: The only way to write 7 as a product is 1 × 7

Primes will be crucial because we'll be doing arithmetic in "mini number systems" based on each prime.

Symmetry

Symmetry means something stays the same when you transform it. A square has 4-fold rotational symmetry: rotate it 90°, and it looks identical. A circle has infinite rotational symmetry: rotate it by any angle, still looks the same.

Mathematical functions can have symmetries too. The function f(x) = x² is symmetric because f(-x) = f(x). This is why its graph (a parabola) is symmetric about the y-axis.

The Big Picture: This proof involves two mathematical objects. One comes from geometry (elliptic curves). One involves functions with elaborate symmetries (modular forms). We'll discover they're secretly the same thing, and that fact proves Fermat's Last Theorem.

Part 1: What Is an Elliptic Curve?

Let's start with something concrete. An elliptic curve i The name is misleading. These curves are NOT ellipses. The name comes from their historical connection to computing the arc length of an ellipse, which requires similar mathematics. is defined by an equation of the form:

y² = x³ + ax + b

Here, a and b are constants you choose. Different choices give different curves.

Some Specific Elliptic Curves

y² = x³ - x (setting a = -1, b = 0)

y² = x³ + 1 (setting a = 0, b = 1)

y² = x³ - 2x + 5 (setting a = -2, b = 5)

What Do These Curves Look Like?

When you plot points (x, y) that satisfy such an equation, you get a smooth curve with a distinctive shape. Notice a key feature: the curves are symmetric about the x-axis. This is because y appears as y², so if (x, y) is on the curve, then (x, -y) is too.

Elliptic Curve · y² = x³ - x + 1
x y 1 2 -1 symmetric If (x, y) is on the curve, so is (x, -y)

The Magic Property: Point Addition

Here's what makes elliptic curves special: you can "add" two points on the curve to get a third point on the curve. The rule is geometric:

Step 1

Take two points P and Q on the curve

Step 2

Draw a straight line through them

Step 3

This line will hit the curve at exactly one other point (call it R')

Step 4

Reflect R' across the x-axis to get R

Result

We define P + Q = R

Adding Points P and Q on an Elliptic Curve
P Q line through P, Q R' reflect P+Q P + Q is the reflection of where the line hits the curve

This might seem like an arbitrary rule, but it has beautiful properties. This "addition" behaves like regular addition:

Property Regular Addition Point Addition
Order doesn't matter 3 + 5 = 5 + 3 P + Q = Q + P
Grouping doesn't matter (2 + 3) + 4 = 2 + (3 + 4) (P + Q) + R = P + (Q + R)
There's a "zero" 5 + 0 = 5 P + O = P (O is a special point "at infinity")
Why This Matters

This algebraic structure (called a "group") is what makes elliptic curves so useful. It's the foundation of elliptic curve cryptography, which secures most of the internet today. When you see the lock icon in your browser, there's a good chance elliptic curves are involved.

Part 2: Counting in Finite Worlds

The fundamental question about elliptic curves is: how many points with rational coordinates i Rational numbers are fractions like 1/2, -3/7, or 5 (which equals 5/1). They're "nice" numbers, as opposed to irrational numbers like π or √2 which have infinite non-repeating decimals. lie on the curve?

This is incredibly hard to answer directly. So mathematicians use a clever workaround: instead of working with all rational numbers, they work with finite fields i A "field" is a number system where you can add, subtract, multiply, and divide (except by zero). A "finite field" is one with only finitely many elements. It's like a tiny universe of numbers. .

What Is a Finite Field?

Pick a prime number p. A finite field 𝔽ₚ (pronounced "F sub p") contains only the numbers 0, 1, 2, ..., p-1. That's it. Just p numbers.

The trick is: all arithmetic "wraps around" when it reaches p. This is called modular arithmetic i You already know this! It's clock arithmetic. On a 12-hour clock, 10 + 5 = 3 because you wrap around past 12. .

Worked Example: Arithmetic in 𝔽₅

In 𝔽₅, we only have the numbers {0, 1, 2, 3, 4}. Let's do some math:

Addition:
3 + 4 = 7, but 7 is too big. Divide by 5, take remainder: 7 = 5×1 + 2, so 3 + 4 = 2
Multiply:
3 × 4 = 12. Divide by 5: 12 = 5×2 + 2, so 3 × 4 = 2
Subtract:
2 - 4 = -2, which is negative. Add 5: -2 + 5 = 3, so 2 - 4 = 3
Powers:
2³ = 8 = 5×1 + 3, so 2³ = 3
Clock Analogy

Think of a clock with p hours instead of 12. In 𝔽₇, if it's 5 o'clock and you wait 4 hours, it becomes 2 o'clock (because 5 + 4 = 9, and 9 - 7 = 2). The numbers just cycle around.

Elliptic Curves Over Finite Fields

Here's the key insight: we can ask the same equation y² = x³ + ax + b, but now x and y are restricted to elements of 𝔽ₚ.

Since there are only finitely many possibilities (p choices for x and p choices for y), we can literally check all of them and count how many satisfy the equation.

Worked Example: y² = x³ + 2 over 𝔽₅

Let's find all solutions where x and y are in {0, 1, 2, 3, 4}.

For each x, we calculate x³ + 2 (mod 5), then check if that's a perfect square in 𝔽₅.

x = 0:
0³ + 2 = 2. Is 2 a square in 𝔽₅? We check: 0²=0, 1²=1, 2²=4, 3²=9=4, 4²=16=1. Squares are {0,1,4}. 2 is NOT a square. No solutions.
x = 1:
1³ + 2 = 3. Is 3 a square? {0,1,4} doesn't include 3. No solutions.
x = 2:
2³ + 2 = 8 + 2 = 10 = 0 (mod 5). Is 0 a square? Yes, 0² = 0. So y = 0. Solution: (2, 0)
x = 3:
3³ + 2 = 27 + 2 = 29 = 4 (mod 5). Is 4 a square? Yes! 2² = 4 and 3² = 4. Solutions: (3, 2) and (3, 3)
x = 4:
4³ + 2 = 64 + 2 = 66 = 1 (mod 5). Is 1 a square? Yes! 1² = 1 and 4² = 1. Solutions: (4, 1) and (4, 4)

Total: 5 points (plus the "point at infinity" = 6 points)

All Points on y² = x³ + 2 over 𝔽₅
0 1 2 3 4 0 1 2 3 4 x → y → 2,0 3,2 3,3 4,1 4,4

Part 3: The Fingerprint Sequence

Mathematicians discovered something remarkable: the number of points on an elliptic curve over 𝔽ₚ follows a predictable pattern.

The Expected Count

For an elliptic curve over 𝔽ₚ, the "expected" number of points is approximately p + 1.

Why p + 1?

Here's the intuition: For each x value (there are p of them), we need y² to equal some value. About half the time, that value will be a perfect square (giving 2 solutions for y), and half the time it won't (giving 0 solutions). On average, that's 1 solution per x value. So we expect roughly p points, plus the point at infinity gives p + 1.

The actual count differs from p + 1 by some amount. We call this difference the error term i Don't be fooled by the name "error." This isn't a mistake. It's the interesting part! The error term encodes deep information about the curve. and denote it εₚ (epsilon sub p):

Number of points = p + 1 + εₚ

Rearranging: εₚ = (actual count) - (p + 1)

Worked Example: Computing Error Terms

For our curve y² = x³ + 2:

Over 𝔽₅:
We found 6 points. Expected: 5 + 1 = 6. So ε₅ = 6 - 6 = 0
Over 𝔽₇:
Count is 7 points. Expected: 7 + 1 = 8. So ε₇ = 7 - 8 = -1
Over 𝔽₁₁:
Count is 12 points. Expected: 11 + 1 = 12. So ε₁₁ = 12 - 12 = 0
Over 𝔽₁₃:
Count is 9 points. Expected: 13 + 1 = 14. So ε₁₃ = 9 - 14 = -5

The Sequence as a Fingerprint

Here's the crucial insight: for each elliptic curve, we get a sequence of error terms, one for each prime:

{ε₂, ε₃, ε₅, ε₇, ε₁₁, ε₁₃, ε₁₇, ε₁₉, ε₂₃, ...}

This sequence is like a fingerprint for the curve. Different curves have different sequences. Two curves with the same fingerprint are essentially the same (in a technical sense).

Fingerprint Sequences for Different Curves

Curve A: y² = x³ + 1

Sequence: {0, 0, -1, 2, -2, -4, 0, 2, ...}

Curve B: y² = x³ - x

Sequence: {0, 0, 2, 0, -2, 0, 2, 0, ...}

Curve C: y² = x³ + 2

Sequence: {-1, 0, 0, -1, 0, -5, 2, 2, ...}

The Hasse-Weil Bound

The error terms can't be arbitrarily large. In 1933, Helmut Hasse proved:

|εₚ| ≤ 2√p

In words: the error is always between -2√p and +2√p.

The Bound in Action

For p = 100: The error must satisfy |ε₁₀₀| ≤ 2√100 = 20

For p = 10000: The error must satisfy |ε₁₀₀₀₀| ≤ 2√10000 = 200

As p grows, the allowed error grows, but only as the square root.

Error Terms Stay Inside a Cone
+2√p -2√p 0 small primes large primes

Summary: Every elliptic curve has a fingerprint sequence {εₚ}, one number for each prime. This sequence uniquely identifies the curve. All the numbers in the sequence are bounded by ±2√p.

Part 4: What Is a Modular Form?

Now for something completely different. A modular form is a function with incredibly strict symmetry requirements. Let's build up to it.

Functions on Complex Numbers

A modular form is a function f that takes a complex number z as input and produces a complex number f(z) as output. But it only cares about complex numbers in the upper half-plane i The upper half-plane consists of all complex numbers a + bi where b > 0. Geometrically, it's everything above the real number line in the complex plane. , which we call ℍ.

The Upper Half-Plane ℍ
Real axis Imaginary upper half-plane not used z = 2 + 1.5i

The Symmetry Requirements

What makes modular forms special is their symmetry. They must behave in specific ways when you transform their input.

The transformations come from 2×2 matrices with integer entries. Specifically, matrices where the determinant i For a 2×2 matrix [a b; c d], the determinant is ad - bc. It measures how the matrix "scales" areas. A determinant of 1 means the matrix preserves area. equals 1:

Matrices of the form [a b; c d] where a, b, c, d are integers and ad - bc = 1

Each such matrix transforms a complex number z to a new complex number:

z → (az + b) / (cz + d)
Two Key Transformations

Translation: The matrix [1 1; 0 1] transforms z → z + 1

This just shifts everything to the right by 1.

Inversion: The matrix [0 -1; 1 0] transforms z → -1/z

This "flips" the plane inside-out around the unit circle.

The Modular Form Condition

A function f is a modular form of weight k if, for every valid matrix transformation:

f((az + b)/(cz + d)) = (cz + d)ᵏ · f(z)

In plain English: when you transform the input in a specific way, the output changes in a predictable way that depends on the weight k.

Analogy: Symmetric Wallpaper

Imagine wallpaper with a repeating pattern. If you shift the wallpaper, the pattern repeats. A modular form is like incredibly elaborate mathematical wallpaper. It has symmetries under shifts, inversions, and combinations of these. The "weight" determines how the pattern scales.

The Fundamental Domain

Because of all these symmetries, the values of a modular form in one small region determine its values everywhere. This region is called the fundamental domain.

Fundamental Domain
0 ½ fundamental domain copy copy z → z+1

The Fourier Coefficients

Because modular forms are periodic (they repeat when you shift by 1), we can express them as a sum of waves. This is called a Fourier series i Named after Joseph Fourier. Any periodic function can be written as a sum of simple oscillating functions. It's like decomposing a musical chord into individual notes. :

f(z) = m₀ + m₁q + m₂q² + m₃q³ + ... where q = e^(2πiz)

The numbers m₀, m₁, m₂, m₃, ... are called the Fourier coefficients. They form a sequence that completely determines the modular form.

Key Point: Just like elliptic curves have a fingerprint sequence {εₚ}, modular forms have a fingerprint sequence {mₙ} of Fourier coefficients.

Part 5: The Impossible Connection

We now have two completely different mathematical objects:

Elliptic Curves Modular Forms
What is it? A curve defined by y² = x³ + ax + b A function with elaborate symmetries
From what field? Algebraic geometry Complex analysis
Its "fingerprint" {εₚ} from counting points mod p {mₙ} from Fourier expansion
How computed? Count solutions in finite fields Expand as infinite series

These objects seem to have nothing in common. They come from different areas of mathematics. Their fingerprint sequences are computed in completely different ways.

And yet...

The Taniyama-Shimura Conjecture

In 1955, two Japanese mathematicians, Yutaka Taniyama and Goro Shimura, made an astounding claim:

The Taniyama-Shimura Conjecture

For every elliptic curve E defined over the rational numbers, there exists a modular form f such that:

The sequences match: εₚ = mₚ for all primes p

In other words: take any elliptic curve. Compute its error term sequence. Somewhere in the world of modular forms, there's a function whose Fourier coefficients are exactly those error terms.

Two Worlds, One Fingerprint
ELLIPTIC CURVES {ε₂, ε₃, ε₅, ε₇, ...} count solutions mod p compare to p+1 MODULAR FORMS {m₁, m₂, m₃, m₄, ...} Fourier coefficients from symmetry = They're the same!

Why Is This Surprising?

It's like discovering that:

Analogies for the Surprise

• The pattern of your fingerprints matches the pattern of ripples in a pond when you throw a rock, computed by totally different means

• The sequence of letters in your name, converted to numbers, exactly matches the Fibonacci sequence

• The way a ball bounces produces the same data as the way a bell rings

Mathematicians expected no connection. The conjecture was radical. Many didn't believe it at first.

But it's true. Between 1995 and 2001, it was proven. The Taniyama-Shimura conjecture is now called the Modularity Theorem.

Part 6: The Proof of Fermat's Last Theorem

Now we can finally explain how this connects to Fermat.

Fermat's Last Theorem

Fermat claimed: For any integer n > 2, the equation

xⁿ + yⁿ = zⁿ

has no solutions in positive integers.

This is obviously true for n = 1 (3 + 4 = 7). For n = 2, there are infinitely many solutions called Pythagorean triples (3² + 4² = 5², for example). But Fermat claimed that for n = 3, 4, 5, ... there are NO solutions.

The Strategy: Proof by Contradiction

The proof works by assuming Fermat is wrong, then deriving a contradiction. Here's the chain of logic:

Step 1: Assume a solution exists

Suppose we have positive integers a, b, c with aⁿ + bⁿ = cⁿ for some n > 2.

Step 2: Build the Frey curve

From these numbers, construct an elliptic curve: y² = x(x - aⁿ)(x + bⁿ). This is called the Frey curve, after Gerhard Frey who proposed this approach in 1984.

Step 3: Ribet's theorem

In 1986, Ken Ribet proved that this Frey curve, if it existed, could NOT be modular. Its fingerprint sequence cannot match any modular form.

Step 4: Wiles' theorem

In 1995, Andrew Wiles proved that every elliptic curve of the type that includes the Frey curve IS modular. Its fingerprint sequence MUST match some modular form.

Contradiction!

The Frey curve cannot be modular (Step 3). The Frey curve must be modular (Step 4). Both cannot be true. Therefore, our assumption in Step 1 was wrong. No solution exists.

The Proof Structure
ASSUME aⁿ + bⁿ = cⁿ exists CONSTRUCT Frey curve E RIBET (1986) E is NOT modular (too weird) WILES (1995) E IS modular (all such curves are) CONTRADICTION! ∴ no solution exists

The Historical Timeline

1637

Fermat writes his famous marginal note claiming to have a proof.

1955

Taniyama and Shimura conjecture that elliptic curves and modular forms are connected.

1984

Frey proposes that a counterexample to Fermat would create a strange elliptic curve.

1986

Ribet proves that Frey's curve cannot be modular, confirming Frey's intuition.

1993

Andrew Wiles announces a proof that all relevant elliptic curves are modular. A gap is found.

1995

Wiles and Richard Taylor fix the gap. Fermat's Last Theorem is finally proven after 358 years.

2001

The full Taniyama-Shimura conjecture is proven for all elliptic curves (not just the types needed for Fermat).

Part 7: Why Does This Work?

We've shown how the proof works. But here's the deeper question: why are elliptic curves and modular forms connected?

The honest answer is: we don't fully understand.

The Modularity Theorem tells us that these two mathematical worlds are secretly the same. Every elliptic curve has a modular form "twin." But the proof doesn't explain why this deep connection exists.

Is there some even deeper mathematical structure that makes this connection inevitable? Or is it a fundamental mystery about the nature of mathematics itself?

This is a pattern in mathematics. Often, we can prove that something is true long before we understand why it's true. The "why" can take decades or centuries more to uncover.

The Nature of Mathematical Discovery

The proof of Fermat's Last Theorem illustrates something profound: mathematics is not just about calculation. It's about finding hidden connections between seemingly unrelated ideas. Wiles didn't solve Fermat directly. He discovered that it was secretly a question about the unity of mathematical structures.

The connection between elliptic curves and modular forms is now seen as part of a much larger picture called the Langlands program i A vast web of conjectures connecting number theory, geometry, and analysis. It's been called a "grand unified theory" of mathematics. The Modularity Theorem is one piece of this larger puzzle. , a grand vision of how different areas of mathematics are unified. But that's a story for another time.

What We've Learned

Let's recap the journey:

Elliptic Curves

Curves defined by y² = x³ + ax + b, with a beautiful "addition" operation on points.

Finite Fields

Mini number systems where arithmetic wraps around. We can count solutions to the curve equation in these fields.

Error Terms

For each prime p, the count differs from p+1 by some amount εₚ. This sequence {εₚ} is the curve's fingerprint.

Modular Forms

Functions with elaborate symmetries. Their Fourier coefficients {mₙ} form another fingerprint.

The Connection

The Modularity Theorem says these fingerprints match: every elliptic curve's {εₚ} equals some modular form's {mₙ}.

Fermat's Proof

A counterexample to Fermat would create an elliptic curve that's both modular and not modular. Contradiction. So no counterexample exists.

The proof of Fermat's Last Theorem is one of the great achievements of human thought. It shows that mathematics is not a collection of isolated tricks, but a deeply connected web of ideas where the resolution of one ancient puzzle can come from completely unexpected directions.

What am I missing? What questions does this raise for you?