Which primes have the form a squared + ab + b squared?

Original publication: Updated:

A companion to the sum-of-two-squares theorem

The prime case of Fermat's sum-of-two-squares theorem says that a prime is a sum of two nonzero integer squares exactly when it is two or is congruent to one modulo four.

A related representation replaces the square lattice of Gaussian integers with the triangular lattice of Eisenstein integers:

p=a2+ab+b2 for nonzero integers a,b⟺p=3 or p≡1(mod3).\boxed{p=a^2+ab+b^2\text{ for nonzero integers }a,b \quad\Longleftrightarrow\quad p=3\text{ or }p\equiv1\pmod3.}

The original article presents an exploratory commutative-algebra proof. The argument below retains its three-stage structure while making the quotient maps, norm bounds, and strict ideal inclusions explicit. This is a companion representation theorem, rather than a claim that the result is new or that it logically contains the sum-of-two-squares theorem.

For example,

3=12+1⋅1+12,7=12+1⋅2+22,13=12+1⋅3+32.3=1^2+1\cdot1+1^2,\quad 7=1^2+1\cdot2+2^2,\quad 13=1^2+1\cdot3+3^2.

There is a quick necessary congruence: a2+ab+b2≡(a−b)2(mod3)a^2+ab+b^2\equiv(a-b)^2\pmod3, so a prime with such a representation is either three or congruent to one. The harder direction is showing that every prime congruent to one has a representation.

The ring and its norm

Put

ω=−1+−32,R=Z[ω].\omega=\frac{-1+\sqrt{-3}}2,\qquad R=\mathbb Z[\omega].

Then ω2+ω+1=0\omega^2+\omega+1=0, and every element of RR has a unique expression u+vωu+v\omega with u,v∈Zu,v\in\mathbb Z. Uniqueness follows because ω\omega is nonreal.

Complex conjugation preserves RR, since ωˉ=−1−ω\bar\omega=-1-\omega. Define

N(z)=zzˉ=∣z∣2.N(z)=z\bar z=|z|^2.

For z=a−bωz=a-b\omega,

N(a−bω)=a2+ab+b2=(a+b2)2+34b2.N(a-b\omega)=a^2+ab+b^2 =\left(a+\frac b2\right)^2+\frac34b^2.

Thus a nonzero element has a positive integer norm, and N(zw)=N(z)N(w)N(zw)=N(z)N(w). An element is a unit exactly when its norm is one: its conjugate then supplies an inverse, while a multiplicative inverse forces the product of two positive integer norms to be one.

For p>3p>3, we will prove

p≡1(mod3) ⟺ (X2+X+1) is not maximal in Fp[X]p\equiv1\pmod3 \ \Longleftrightarrow\ (X^2+X+1)\text{ is not maximal in }\mathbb F_p[X] ⟺ pR is not maximal in R ⟺ p=N(a−bω).\Longleftrightarrow\ pR\text{ is not maximal in }R \ \Longleftrightarrow\ p=N(a-b\omega).

Here (f)(f) is the ideal of multiples of ff. An ideal is maximal when it is proper and no ideal lies strictly between it and the whole ring.

Stage 1: factor a polynomial over a finite field

Why every ideal of the polynomial ring is principal

Let II be a nonzero ideal of Fp[X]\mathbb F_p[X], and choose a nonzero polynomial A∈IA\in I of least degree. Divide any f∈If\in I by AA:

f=AQ+S,deg⁡S<deg⁡A if S≠0.f=AQ+S,\qquad\deg S<\deg A\text{ if }S\ne0.

The remainder S=f−AQS=f-AQ also lies in II, so minimality forces S=0S=0. Thus I=(A)I=(A). The zero ideal is (0)(0) as well.

Consequently, for the monic quadratic h=X2+X+1h=X^2+X+1, the ideal (h)(h) fails to be maximal exactly when hh factors into linear factors. If h=(X−u)(X−v)h=(X-u)(X-v), then

(h)⊊(X−u)⊊Fp[X].(h)\subsetneq(X-u)\subsetneq\mathbb F_p[X].

Conversely, an ideal strictly between (h)(h) and the whole ring has a generator of degree one, and that generator divides hh.

When does the quadratic split?

For p>3p>3, a repeated root is impossible. A common root of hh and h′=2X+1h'=2X+1 would be −1/2-1/2, but h(−1/2)=3/4≠0h(-1/2)=3/4\ne0 in Fp\mathbb F_p.

By Fermat's little theorem,

Xp−1−1=∏u∈Fp×(X−u).X^{p-1}-1=\prod_{u\in\mathbb F_p^\times}(X-u).

The roots of hh, if present, are distinct and nonzero. Hence hh splits over Fp\mathbb F_p exactly when it divides Xp−1−1X^{p-1}-1.

To determine that divisibility, work modulo hh. Since X3−1=(X−1)hX^3-1=(X-1)h, we have X3≡1(modh)X^3\equiv1\pmod h.

  • If p≡1(mod3)p\equiv1\pmod3, then p−1p-1 is divisible by three, so Xp−1−1≡0(modh)X^{p-1}-1\equiv0\pmod h.
  • If p≡2(mod3)p\equiv2\pmod3, then p−1≡1(mod3)p-1\equiv1\pmod3, so the remainder is X−1X-1, which is nonzero and has degree less than two.

A prime greater than three is not divisible by three. This proves the first equivalence.

Stage 2: identify the quotient ring

Evaluation at ω\omega gives a surjective homomorphism

Z[X]⟶R,f⟼f(ω).\mathbb Z[X]\longrightarrow R,\qquad f\longmapsto f(\omega).

Its kernel is (h)(h). Indeed, division by the monic polynomial hh works with integer coefficients, giving f=hq+(u+vX)f=hq+(u+vX). If f(ω)=0f(\omega)=0, then u+vω=0u+v\omega=0, forcing u=v=0u=v=0.

Therefore

R≃Z[X]/(h).R\simeq\mathbb Z[X]/(h).

Reducing coefficients modulo pp gives

R/pR≃Z[X]/(p,h)≃Fp[X]/(h).\boxed{R/pR\simeq\mathbb Z[X]/(p,h) \simeq\mathbb F_p[X]/(h).}

These are ring isomorphisms. A quotient by a proper ideal is a field exactly when that ideal is maximal. Hence (h)(h) is maximal in Fp[X]\mathbb F_p[X] exactly when pRpR is maximal in RR.

One can also express this through the ideal correspondence: ideals containing a kernel correspond to ideals in the quotient by image and inverse image. It is the correspondence on ideals that is bijective; the original reduction homomorphism is generally not injective.

Stage 3: every ideal of R is principal

We need Euclidean division for the norm. Given complex zz, express it uniquely as s+tωs+t\omega with real s,ts,t. Round s,ts,t to nearest integers m,nm,n, and put q=m+nωq=m+n\omega. Then

z−q=u+vω,∣u∣,∣v∣≤12,z-q=u+v\omega,\qquad |u|,|v|\le\frac12,

and

∣z−q∣2=u2−uv+v2≤34<1.|z-q|^2=u^2-uv+v^2\le\frac34<1.

For α,β∈R\alpha,\beta\in R with α≠0\alpha\ne0, apply this to z=β/αz=\beta/\alpha. With r=β−qαr=\beta-q\alpha,

β=qα+r,N(r)<N(α).\beta=q\alpha+r,\qquad N(r)<N(\alpha).

The lattice directions alpha and omega times alpha span a rhombus in the complex plane.

The lattice picture motivates approximation, but the centered rounding estimate above supplies the strict norm bound. An arbitrary point in an uncentered fundamental rhombus need not have smaller norm than its edge length.

Now choose a nonzero element α\alpha of a nonzero ideal II with least positive norm. Dividing any β∈I\beta\in I by α\alpha leaves r∈Ir\in I. The strict norm bound forces r=0r=0. Thus I=(α)I=(\alpha). The zero ideal is principal too.

From a nonmaximal ideal to a norm representation

Suppose pRpR is not maximal. Since it is proper, there is an ideal

pR⊊I⊊R.pR\subsetneq I\subsetneq R.

Write I=(α)I=(\alpha). Because p∈Ip\in I, we have p=αβp=\alpha\beta for some β∈R\beta\in R. Both factors are nonzero, and

p2=N(α)N(β).p^2=N(\alpha)N(\beta).

The positive integer norm pairs can only be (1,p2)(1,p^2), (p,p)(p,p), or (p2,1)(p^2,1). If N(α)=1N(\alpha)=1, then α\alpha is a unit, contradicting I≠RI\ne R. If N(β)=1N(\beta)=1, then α\alpha is associated to pp, contradicting I≠pRI\ne pR.

Therefore N(α)=pN(\alpha)=p. Write α=a−bω\alpha=a-b\omega to obtain

p=a2+ab+b2.p=a^2+ab+b^2.

Neither coefficient can be zero: otherwise a prime would be an integer square.

From a representation to a nonmaximal ideal

Conversely, suppose p=N(α)p=N(\alpha) for α=a−bω\alpha=a-b\omega. Since p=ααˉp=\alpha\bar\alpha, we have pR⊆(α)pR\subseteq(\alpha). The ideal (α)(\alpha) is proper because its generator has norm p>1p>1 and is not a unit.

The inclusion is strict. If α=pγ\alpha=p\gamma for some γ∈R\gamma\in R, then p=N(α)=p2N(γ)p=N(\alpha)=p^2N(\gamma), impossible for a positive integer N(γ)N(\gamma). Thus α∉pR\alpha\notin pR and

pR⊊(α)⊊R.pR\subsetneq(\alpha)\subsetneq R.

This proves the last equivalence.

Finish the exceptional primes

All three stages apply for p>3p>3. For p=3p=3, take a=b=1a=b=1. For p=2p=2, the congruence a2+ab+b2≡(a−b)2(mod3)a^2+ab+b^2\equiv(a-b)^2\pmod3 rules out a representation because two is not a square modulo three.

We have therefore proved the criterion for every prime, with the required nonzero coefficients. The central connection is that factorization of a polynomial modulo pp detects the failure of pp to remain prime in a larger ring, and the multiplicative norm turns that factorization into an integer representation.

Related articles

About the author

Koki Saito

Physician and graduate of the University of Tokyo Faculty of Medicine. Drawing on his entrance-exam experience, he explains how to choose mathematical methods and construct complete solutions.

Full profile →

Have a question or spotted an error? Contact us.