## The Pell Equation

Going back a little, one part of elementary number theory that’s intimately connected to Dirichlet’s theorem on units is the Pell equation, a^2 – nb^2 = 1. Normally, n is restricted to be positive and not divisible by any square greater than 1; if n < 0 then the equation is trivial, and if n = mc^2 then the equation just becomes a^2 – m(bc)^2 = 1.

By Dirichlet’s theorem, the unit group of a real quadratic field Q(SQRT(n)) is Z * W, where W is the group of roots of unity. The only real roots of unity are 1 and -1, so W is just {1, -1} = C(2) = Z/2Z, and it’s fairly easy to show that the group of all positive units is Z. That already gives solutions to the Pell equation other than the trivial one a = (+/-)1, b = 0 – but note that actually finding a solution is more difficult.

Given that, it’s interesting to ask what the equivalent of 1 in Z is, i.e. what the smallest unit in Q(SQRT(n)) that’s greater than 1 is. If we’re already given a unit a + bSQRT(n), we can always calculate the smallest unit as a root of a + bSQRT(n). If the smallest unit is c + dSQRT(n), then expanding (c + dSQRT(n))^m shows that all terms containing SQRT(n) also contain d, so that d divides b. Also, if m is odd then all rational terms contain c so that c divides a, while if m is even then c divides b. This gives finitely many possibilities for c and d, which can be checked directly (caveat: if n = 1 mod 4, then this needs to be slightly tweaked to account for the fact that a and b can be half-integers).

I’ll spare you the derivation of non-trivial units – if you’re interested, just reread the post proving Dirichlet’s theorem, play with b and h a little, and thank the FSM you only have to deal with one linearly independent unit. But from the above, it immediately follows that the smallest unit in Z[SQRT(2)] is 1 + SQRT(2). For proof that the smallest unit in Z[SQRT(3)] is 2 + SQRT(3), note that d = 1 or else c + dSQRT(3) <= 2 – SQRT(3) < 1, and then c = 2, because N(1 + SQRT(3)) = -2 != (+/-)1.

A few eons ago, when reflecting on the problem with proving that there are no integer solutions to x^2 – 2 = y^3, I said that every unit of Z[SQRT(2)] is (+/-)1 times a product of some copies of 1 + SQRT(2) or its inverse, -1 + SQRT(2). This is the proof of that. In fact, once you note that 1 + SQRT(2) is a unit, you don’t need Dirichlet’s theorem; any unit not of the above form will induce a unit between 1 and 1 + SQRT(2), which the argument with c and d is enough to show is a contradiction.

Although a unit a + bSQRT(n) can have norm -1, whereas the Pell equation requires the norm to be 1, we can always use (a + bSQRT(n))^2, which is a unit of norm (-1)^2 = 1. But this suggests looking at a related equation, a^2 – nb^2 = -1. This equation isn’t always solvable – for example, if n = 3, then the smallest unit has norm 1 and so does the unit -1, which implies that so do all units.

In fact, if n = 3 mod 4, then the equation is never solvable, because mod 4 is becomes a^2 + b^2 = 3, which is impossible. This generalizes to the case where n is even divisible by a prime p that’s equivalent to 3 mod 4, because mod p the equation is a^2 = -1, which is again impossible (proof: if a^2 = -1 mod p then a is a primitive 4th root of unity mod p, which is impossible because the multiplicative group mod p is C(p-1), whose size is not divisible by 4).