1. Introduction
Pierre de Fermat was not a professional mathematician. Trained as a lawyer, he served as a councillor in the Parlement of Toulouse. Mathematics was his "second trade," pursued in evenings and in letters to friends like Marin Mersenne, Blaise Pascal, and René Descartes.
He rarely published. Instead, he announced results, challenged others, and scribbled notes in the margins of his copy of Diophantus' Arithmetica. It was there in 1637 that he wrote his most famous marginal note — a claim that would take 358 years to prove.
Despite being an amateur, Fermat founded modern number theory, co-founded probability theory, developed analytic geometry independently of Descartes, and created a method for maxima and minima that foreshadowed calculus. Carl Friedrich Gauss called him "the prince of amateurs" because his insights were so profound.
2. Number Theory Foundations
Fermat's central legacy is number theory — the study of integers. He discovered patterns where others saw chaos.
Fermat's Little Theorem
If p is prime and p does not divide a, then:
ap−1 ≡ 1 (mod p)
Proof idea: Consider the multiples a, 2a, 3a, ..., (p−1)a modulo p. They are a rearrangement of 1,2,...,p−1. Multiply them all: ap−1(p−1)! ≡ (p−1)! (mod p). Cancel (p−1)! to get the theorem.
% GNU Octave - Fermat's Little Theorem
function r = powmod(a, e, m)
r = 1;
a = mod(a, m);
while e > 0
if bitand(e,1)
r = mod(r * a, m);
endif
e = bitshift(e, -1);
a = mod(a * a, m);
endwhile
endfunction
p = 17; a = 3;
powmod(a, p-1, p) % returns 1
Fermat Primes
Fermat conjectured all numbers of the form Fn = 22n + 1 are prime. He was right for n = 0–4, wrong thereafter.
Status:
Factors:
% GNU Octave
for n = 0:6
Fn = 2^(2^n) + 1;
printf("F_%d = %d\n", n, Fn);
endfor
% F5 = 4,294,967,297 = 641 * 6,700,417 (Euler, 1732)
Sums of Two Squares
Fermat's theorem on sums of two squares (Christmas Theorem, 1640): An odd prime p is expressible as p = x² + y² iff p ≡ 1 (mod 4).
% GNU Octave
p = 29;
if mod(p,4)==1 || p==2
for x = 0:floor(sqrt(p))
y2 = p - x^2;
y = sqrt(y2);
if y == floor(y)
printf("%d = %d^2 + %d^2\n", p, x, y); break;
endif
endfor
endif
3. Fermat's Last Theorem
In 1637, Fermat wrote: "Cubum autem in duos cubos... nullam solutionem, hanc marginis exiguitas non caperet" — there are no positive integers a, b, c with an + bn = cn for n > 2.
Proof for n=4: Fermat did prove the case n=4 using infinite descent. Suppose a⁴+b⁴=c⁴ has a solution. Then there is a smaller solution, and a smaller one ad infinitum — impossible in positive integers. The key is to show it reduces to finding two squares whose sum and difference are squares.
No counterexamples will be found. Andrew Wiles proved the full theorem in 1994 using modular forms and elliptic curves.
% GNU Octave - brute force check for n=4
n = 4; M = 30;
found = false;
for a = 1:M
for b = a:M
s = a^n + b^n;
c = round(s^(1/n));
if c^n == s
found = true; printf("%d^%d + %d^%d = %d^%d\n", a,n,b,n,c,n);
endif
endfor
endfor
4. Method of Adequality (1636)
Thirty years before Newton and Leibniz, Fermat developed a technique for maxima, minima, and tangents. He called it adequality (from Latin adaequare, to equalize).
Steps: 1) Set f(x) ≈ f(x+e). 2) Cancel common terms. 3) Divide by e. 4) Discard remaining terms containing e.
This is essentially setting the derivative to zero, but without limits.
Find maximum of f(x) = x(10 − x) — the rectangle with perimeter 20.
Adequality gives: 0 ≈ 10e − 2xe − e² → divide by e → 10 − 2x − e ≈ 0 → as e vanishes, x = 5.
% GNU Octave (symbolic package)
pkg load symbolic
syms x e
f = x*(10 - x);
adeq = expand(subs(f, x, x+e) - f); % = 10e - 2*x*e - e^2
q = adeq / e; % = 10 - 2*x - e
solve(q == 0, x) % x = 5 - e/2, limit e->0 gives 5
5. Analytic Geometry
Independently of Descartes (and earlier, in manuscript form in 1629), Fermat introduced coordinate geometry in Ad Locos Planos et Solidos Isagoge. He studied loci like y² = ax — what we call a parabola.
Fermat wrote equations as proportions. y² = ax describes points whose distance to the axis squared is proportional to distance along axis.
% GNU Octave
a = 2;
y = -10:0.1:10;
x = y.^2 / a;
plot(x, y); axis equal; grid on;
title("Fermat parabola y^2 = a x");
6. Probability with Pascal (1654)
Fermat's correspondence with Blaise Pascal founded probability theory. They solved the "problem of points": how to fairly divide stakes when a game stops early.
Another famous question: Is it advantageous to bet on at least one six in 4 throws of a die? Fermat computed exactly using combinatorial reasoning.
% GNU Octave
N = 100000;
rolls = randi(6, N, 4);
wins = sum(any(rolls == 6, 2));
prob = wins / N % ≈ 0.5177
7. Fermat's Principle in Optics (1662)
Fermat's last great contribution: light travels between two points by the path of least time, not distance. From this he derived Snell's law of refraction.
If light goes from medium 1 (speed v₁) to medium 2 (v₂), it minimizes T = d₁/v₁ + d₂/v₂. This gives n₁ sin θ₁ = n₂ sin θ₂, where n = c/v.
% GNU Octave - least time
n1 = 1.0; n2 = 1.33; % air to water
x1 = -4; y1 = 3; x2 = 4; y2 = 3;
T = @(x) n1*sqrt((x-x1)^2 + y1^2) + n2*sqrt((x2-x)^2 + y2^2);
x_opt = fminbnd(T, x1, x2); % ≈ 0.86