Number

Which way a prime's two squares point

A prime one more than a multiple of four is a sum of two squares in exactly one way, and the two squares make a point on a circle. Draw that point for every such prime and ask which way it faces. It faces every way equally — the angles spread evenly over the sector, which Hecke proved by giving each angle a remainder and copying Dirichlet. Measured over seventy-four thousand primes, they are even more evenly spread than random angles would be.

Worth reading first: Two squares, and a lattice · A fraction on the circle forces a whole point.

Thirteen is 32+223^2 + 2^2. Seventeen is 42+124^2 + 1^2, twenty-nine is 52+225^2 + 2^2, thirty-seven is 62+126^2 + 1^2, forty-one is 52+425^2 + 4^2. Every prime that leaves a remainder of one on division by four is a sum of two squares, and the rule that decides which primes are also says the two squares are unique: once the larger is written first and signs are ignored, there is exactly one pair. So each such prime pp comes with a single point (a,b)(a, b), with a>b>0a > b > 0, sitting on the circle of radius p\sqrt p.

A point on a circle has a direction. Seventeen’s point (4,1)(4, 1) lies almost flat, fourteen degrees above the horizontal; forty-one’s point (5,4)(5, 4) is nearly on the diagonal, at thirty-nine degrees. The question this essay asks is the most naive one available: which way do the primes face? Is there a favoured direction — do primes prefer to be one large square plus a small one, or two squares of about the same size — or does every direction get its fair share?

The answer is that every direction gets its fair share, exactly. Erich Hecke proved it in two papers published in 1918 and 1920, and the proof is a copy, in a new setting, of the argument that puts infinitely many primes into every arithmetic progression. The figures below measure the theorem on the seventy-four thousand primes of this kind below two million — and find something the theorem does not say.

One point for each prime

Draw the point (a,b)(a, b) for every prime one more than a multiple of four, below twenty thousand.

Each prime of the form 4k + 1 as a point on its own circle. Points (a, b) with a > b > 0 and a² + b² prime, for the 1125 such primes below 20000, filling the sector between 0° and 45°.
Fig. 1 The 1,125 primes of the form 4k + 1 below twenty thousand, each written as a2+b2a^2 + b^2 with a>b>0a > b > 0 and plotted at (a,b)(a, b). The three faint arcs are circles of radius 50, 100 and 20,000\sqrt{20{,}000}; each prime’s point lies on its own circle, between the horizontal axis and the 45° line, and the sector is filled with no visible preference for any direction.

The points fill a wedge, one-eighth of a disc. Their density thins slowly outwards, which is the primes thinning — a number near xx is prime with chance about 1/log⁡x1/\log x, and that is all the radial fading is. Around each circle there is no visible pattern at all. No ray through the origin is crowded with points, and none is empty.

That absence is the whole content of Hecke’s theorem, and it is worth saying why it is not obvious. The points (a,b)(a, b) are lattice points: whole-number coordinates. The lattice points on circles are rigidly arranged, and their arrangement is invisible from the outside — the question of whether a2+b2a^2 + b^2 is prime depends on aa and bb in a way that has nothing to do with angles. There could perfectly well have been a bias. Primes are odd, so aa and bb have opposite parity; primes are not multiples of three, so aa and bb are not both multiples of three. Every such condition is a restriction on the lattice, and each could, in principle, favour some directions over others. The figure says that none does, at least visibly, at this size.

There is also a reason to expect evenness, and stating it shows what has to be proved. The number of lattice points in a wedge of the disc of radius RR is about the wedge’s area, 12θR2\tfrac12 \theta R^2, so whole-number points are spread over directions in proportion to angle. If primality were a coin tossed independently for each point — with the right bias, 1/log⁡1/\log of the squared radius — then primes would inherit that evenness. Hecke’s theorem says the coin really does behave as if it ignores direction, which is a statement about primes and not about lattices.

Why a sector and not the whole circle

The wedge from nought to forty-five degrees is not an arbitrary choice; it is what the arithmetic leaves after its symmetries are removed.

The cleanest way to see it is through the Gaussian integers, the numbers a+bia + bi with aa and bb whole. In them, a prime p=a2+b2p = a^2 + b^2 splits as (a+bi)(a−bi)(a + bi)(a - bi), and the norm a2+b2a^2 + b^2 is the squared distance from the origin. A prime that factors this way has its factor determined only up to two kinds of ambiguity. Multiplying by the units ii, −1-1, −i-i rotates the factor by a right angle without changing anything that matters, so the factor’s angle is really only defined modulo ninety degrees. And swapping a factor for its conjugate a−bia - bi reflects the angle in the horizontal. Together those eight operations — four rotations, each with or without a reflection — carry the point (a,b)(a, b) to (±a,±b)(\pm a, \pm b) and (±b,±a)(\pm b, \pm a), and exactly one of the eight lies between the horizontal and the diagonal.

So the sector is the circle with its symmetry quotiented out, and evenness in the sector is the same statement as evenness of the Gaussian prime factors around the whole circle. That matters for the proof, because it is the Gaussian factors, not the folded angles, on which Hecke’s method runs. And it matters for the measurement, because a prime’s angle is now a number θ\theta between 00 and π/4\pi/4 with nothing further to adjust: one prime, one angle.

No direction is preferred

Seventy-four thousand primes are enough to measure the claim rather than eyeball it. Cut the sector into forty-five bands of one degree each and count how many primes below two million land in each.

The angles of the primes, against an even spread. Histogram of the angles arctan(b/a) for 74416 primes a² + b² below two million in 45 one-degree bands, each normalised by its expected share; all lie between 0.968 and 1.024.
Fig. 2 The angles of the 74,416 primes of the form 4k + 1 below two million, in one-degree bands, each band drawn as its departure from the count an even spread predicts — above the line where the band has more than its share, below where it has fewer. The vertical scale spans only six per cent either way; every band lies within four per cent of its share.

The bands sit within a few per cent of their share, and there is no trend across the sector — no slope from the horizontal to the diagonal, no hump in the middle. Note the vertical scale: it runs from six per cent short to six per cent over, and an even spread over seventy-four thousand points, divided into forty-five bands of about sixteen hundred each, would be expected to wander by about two and a half per cent per band from chance alone. The departures drawn here are the size of noise.

One band is visibly short: the first, below one degree, at three per cent under. That is not a bias in the primes but a fact about small numbers. A point with angle below one degree needs b<atan⁡1°≈a/57b < a \tan 1° \approx a/57, and with bb at least one that forces a>57a > 57, so no prime below about 3,3003{,}300 can contribute to that band at all. The sliver nearest the axis opens late, and over a range that begins at five it starts behind. The same effect, much smaller, shortens the band nearest the diagonal, where a>ba > b must be strict. Both are effects of the range having a floor, and both shrink as the range grows.

It is worth registering how different this is from the question of how many numbers are sums of two squares at all. That count drifts, slowly and provably, towards a share of nothing; no finite computation shows its limit. The angles have no such drift. Whatever the slow corrections to the count of primes in a sector are, they are the same correction in every sector, and they cancel when one sector is compared with another.

Remainders and angles, one theorem

Hecke’s proof is the reason this essay sits where it does, and it is a precise imitation of a proof that is a century older.

Dirichlet’s theorem says that primes fall evenly into the allowed remainders modulo any number qq — a quarter of all large primes end in each of the digits 1, 3, 7 and 9. Dirichlet’s method attaches to each remainder class a set of characters: functions χ\chi that turn a remainder into a complex number of size one and respect multiplication, χ(mn)=χ(m)χ(n)\chi(mn) = \chi(m)\chi(n). From each character he built a series L(s,χ)=∑χ(n)n−sL(s, \chi) = \sum \chi(n) n^{-s}, which factors over primes just as the zeta function does. The averages of χ\chi over primes are what decide whether the primes are evenly spread among the remainders, and those averages tend to nought exactly because no L(s,χ)L(s, \chi) is zero at s=1s = 1.

An angle is a remainder that varies continuously. The direction of a Gaussian integer a+bia + bi is a number modulo ninety degrees, and multiplying two Gaussian integers adds their angles, just as multiplying two numbers multiplies their remainders. So the functions that respect this multiplication are λk(a+bi)=e4ikθ′\lambda_k(a + bi) = e^{4ik\theta'}, where θ′\theta' is the angle, for every whole number kk — the factor four makes them indifferent to the units. These are Hecke’s Größencharaktere, characters that measure size and direction. From each he built an L-function, proved that it continues past the line where its series stops converging and that it has no zero on that line, and drew the conclusion Dirichlet had drawn: the average of each character over the primes tends to nought.

That those averages decide evenness is Hermann Weyl’s criterion, from 1916. For the folded angle in the sector it reads: the angles θ\theta are evenly spread exactly when, for every k≥1k \ge 1, the average of cos⁡4kθ\cos 4k\theta over the primes tends to nought. The cosines are what is left of λk\lambda_k once each prime’s factor is paired with its conjugate. The first four can be measured.

The four averages that decide the evenness, first of infinitely many. k = 1: 0.0336, 0.0259, 0.0120, 0.0061, 0.0032, 0.0015, 0.0008, 0.0009; k = 2: 0.0519, 0.0421, 0.0088, 0.0053, 0.0027, 0.0035, 0.0014, 0.0011; k = 3: 0.0203, 0.0369, 0.0027, 0.0037, 0.0033, 0.0022, 0.0007, 0.0008; k = 4: 0.0901, 0.0031, 0.0219, 0.0054, 0.0016, 0.0017, 0.0015, 0.0012.
Fig. 3 For each bound, the size of the average of cos 4kθ over the angles of every prime a2+b2a^2 + b^2 up to it, for k = 1, 2, 3 and 4, on logarithmic scales, beside the line 1/n1/\sqrt n. Each average falls towards nought, to about a thousandth at two million. Weyl’s criterion asks for every k; the kth is the average that the kth of Hecke’s L-functions governs.

All four fall, and they fall together. At two million each is about one part in a thousand. The figure shows four of an infinite list, and the theorem is that the list ends nowhere: however rapid the oscillation — cos⁡400θ\cos 400\theta, swinging a hundred times across the sector — its average over the primes eventually goes to nought too. The picture can show the first few. Only the L-functions handle all of them at once, which is why the result is Hecke’s and not a computation’s.

The parallel with the prime number theorem runs one level deeper. The count of primes below xx is governed by the zeta function, and the proof that the count is asymptotically right is, at its core, the proof that zeta has no zero on the line Re⁡s=1\operatorname{Re} s = 1. Hecke’s theorem is the same statement for each of his L-functions. The angles are evenly spread for exactly the reason the primes are as numerous as they are.

Measured against chance

Evenness is a statement about the limit. It says nothing about how quickly the counts settle, and that is where the measurements found something the theorem does not predict.

The natural yardstick is the discrepancy: list the angles, and for each tt compare the share of them below tt with the share t/45°t/45° an even spread would have; the discrepancy is the largest difference. It is the measure used for the fractions with bounded denominator, where its rate of decay is equivalent to the Riemann hypothesis. For nn independent random angles it is about 0.87/n0.87/\sqrt n on average — that number is the mean of Kolmogorov’s limiting distribution, and it is the size against which any set of points can be called more or less even than chance.

How fast the angles become even. 1000: 80 primes, discrepancy 0.0634 against 0.1010 for random draws; 3000: 211 primes, discrepancy 0.0410 against 0.0569 for random draws; 10000: 609 primes, discrepancy 0.0169 against 0.0339 for random draws; 30000: 1611 primes, discrepancy 0.0101 against 0.0208 for random draws; 100000: 4783 primes, discrepancy 0.0061 against 0.0125 for random draws; 300000: 12980 primes, discrepancy 0.0039 against 0.0076 for random draws; 1000000: 39175 primes, discrepancy 0.0018 against 0.0044 for random draws; 2000000: 74416 primes, discrepancy 0.0016 against 0.0031 for random draws.
Fig. 4 The discrepancy of the prime angles up to each bound, from a thousand to two million (warm), beside the same measurement for as many independent random angles, averaged over forty trials (dashed), on logarithmic scales. The primes’ discrepancy is below the random line at every bound, by a factor close to two.

The primes’ discrepancy sits below the random line at every one of the eight bounds, and the ratio holds steady: scaled by n\sqrt n, it reads 0.570.57 at a thousand primes and stays between 0.370.37 and 0.440.44 from ten thousand to two million, against 0.870.87 for random draws. The cosine averages in the previous figure say the same from another side. For random angles, the average of cos⁡4kθ\cos 4k\theta has typical size about 0.7/n0.7/\sqrt n; the primes’ averages sit between a fifth and a third of 1/n1/\sqrt n at the largest bounds.

So the angles are not merely even in the limit and random in their fluctuations. At every size measured, they are more even than chance. The statement is about the range that was computed, and the factor near two is a measurement rather than a theorem; no result in the literature this essay draws on predicts it. Part of it is certainly the lattice showing through. Lattice points in a sector are not random at all — their count is the sector’s area with an error far smaller than random fluctuation would give — and primes are a thinning of those points by a rule blind to direction. A thinned lattice keeps some of the lattice’s regularity, and the rate at which that inherited regularity is diluted as the primes thin out is not something these eight bounds can settle. A set of points chosen to be more even than random is exactly what a numerical integrator wants. The primes, it seems, supply such points for free.

Thin sectors fill late

Hecke’s theorem is about a fixed sector — any interval of angles, chosen once, then held while the primes grow. What happens when the sector is very narrow?

Thinner sectors take longer to fill. 9.000°: 128/121.8, 954/956.6, 7842/7835.0, 14872/14883.2; 3.000°: 39/40.6, 320/318.9, 2609/2611.7, 4928/4961.1; 1.000°: 14/13.5, 108/106.3, 874/870.6, 1636/1653.7; 0.333°: 5/4.5, 36/35.4, 290/290.2, 542/551.2; 0.111°: 0/1.5, 13/11.8, 97/96.7, 183/183.7.
Fig. 5 For sectors beginning at 20° and spanning from nine degrees down to a ninth of a degree, the number of primes a2+b2a^2 + b^2 up to each bound whose angle lies inside, beside the number an even spread predicts. Shaded cells are more than ten per cent away from the prediction; they are the narrowest sectors at the smallest bounds.

A nine-degree sector holds its share from the start: 128 primes against a prediction of 122 below ten thousand, 14,872 against 14,883 below two million. A sector of a ninth of a degree is empty below ten thousand, where one and a half primes were expected, and then catches up: 183 against 184 at two million. Every row converges. The narrower the sector, the later it settles — a sector that holds few points at a given size is at the mercy of how those few fall.

That is all the theorem promises, and it raises the sharper question that matters more. A sector that is fixed is eventually filled. What about a sector that shrinks as the primes grow — one whose width is a power of 1/p1/p, so that for primes near pp it is very thin indeed? The theorem’s proof comes with an error term, and an error term says how narrow a sector can be while its count is still guaranteed to be right; that guarantee reaches only sectors much wider than the ones in the bottom rows of the table. Asking for less — not the full share, only infinitely many primes — reaches further. Jonas Kubilius in the 1950s was the first to put primes into sectors whose width is a negative power of pp, and Glyn Harman and Paul Lewis proved in 2001, by sieve methods rather than L-functions alone, that infinitely many primes a2+b2a^2 + b^2 have bb below p0.119p^{0.119} — that is, an angle below about p−0.38p^{-0.38}.

The thinnest sector of all

Push the sector as thin as it can go and keep bb at one. Then p=a2+1p = a^2 + 1, and its point lies at angle about 1/a1/a, the smallest angle any lattice point on that circle can have short of the axis itself. Asking whether this sliver holds infinitely many primes is asking whether infinitely many primes are one more than a square.

Primes in the thinnest sectors: one more than a square, and its cousins. b = 1: 152 primes below two million; b = 2: 168 primes below two million; b = 3: 102 primes below two million; b = 4: 161 primes below two million.
Fig. 6 The number of primes a2+1a^2 + 1, a2+4a^2 + 4, a2+9a^2 + 9 and a2+16a^2 + 16 as a runs up to 1,414 — each a prime whose second square is fixed and whose point lies ever closer to the horizontal axis. The counts keep rising for all four, and a2+9a^2 + 9 runs lowest because it is divisible by 3 whenever a is.

All four counts rise steadily: 152 primes of the form a2+1a^2 + 1 below two million, 168 of the form a2+4a^2 + 4, 102 of the form a2+9a^2 + 9 and 161 of the form a2+16a^2 + 16. The gaps between them have plain explanations. a2+1a^2 + 1 and a2+9a^2 + 9 must have aa even, or they are even themselves; a2+4a^2 + 4 and a2+16a^2 + 16 must have aa odd. And a2+9a^2 + 9 is a multiple of three whenever aa is, which removes a third of its candidates outright — the curve drawn lowest. Conditions of exactly this kind are what the primes on Ulam’s spiral line up along, and the heuristic of Hardy and Littlewood turns them into a predicted count for each polynomial. For a2+1a^2 + 1 the prediction is about 1.371.37 times the count for random numbers of the same size, and it matches every computation ever made.

It is not proved. Whether infinitely many primes are one more than a square was the fourth of the problems Edmund Landau listed at the International Congress in 1912 as unattackable by the methods of his day, and it remains open. The nearest results go round it. Henryk Iwaniec proved in 1978 that a2+1a^2 + 1 is infinitely often a prime or a product of two primes. John Friedlander and Iwaniec proved in 1998 that infinitely many primes are a2+b4a^2 + b^4 — a sum of two squares in which the second is itself a square, so that the points are sparse in a different way. Neither reaches b=1b = 1.

So the sector picture sets the problem in a scale. Hecke places infinitely many primes in every fixed sector. Harman and Lewis place infinitely many in sectors as thin as p−0.38p^{-0.38}. Landau’s problem is the sector of width p−1/2p^{-1/2} — the thinnest the lattice allows. The distance between those exponents is the distance between what is known and what is believed.

Two million primes standing in for all of them

The figures count to two million, and each claim they illustrate is about all primes. That every fixed sector receives exactly its share in the limit is Hecke’s theorem and is proved; the figures show it happening, not that it must. Weyl’s criterion needs every cosine average to tend to nought, and the figure draws four of infinitely many, each over a finite range.

The observation that the angles are more even than random is the opposite case: it is visible in every figure and proved nowhere here. Its factor of two holds across eight bounds spanning three orders of magnitude, and nothing in the computation says whether it is permanent, slowly fading, or a feature of the particular range. The neighbouring fact — that the count of lattice points in a wedge is far more regular than random — suggests a mechanism, and turning a suggestion into a statement about primes would take control of the L-functions’ zeros well beyond what the equidistribution proof needs.

And nothing in a figure can show that the sector of width one square holds infinitely many primes. One hundred and fifty-two below two million is evidence of exactly the kind that has been accumulating since Euler, and Landau’s problem is open because no amount of it is proof. The picture locates the problem precisely — at the bottom edge of the wedge, in the sliver of width 1/a1/a — and stops there.

Still open: how thin a sector a prime must visit

The quantitative form of Hecke’s theorem is the open edge. It is conjectured that a sector of width p−1/2+εp^{-1/2 + \varepsilon}, for any ε>0\varepsilon > 0, eventually holds its share of primes. Even the Riemann hypothesis for every one of Hecke’s L-functions, used in the standard way, guarantees the share only in sectors far wider than that, because a narrow sector needs many characters at once and each brings its own error. Proved results place infinitely many primes — not their share — in sectors down to p−0.38p^{-0.38}. Between the two lie all the questions about primes in thin sectors, and at the far end lies b=1b = 1, which is Landau’s problem.

A second question is about the size of the fluctuations rather than the reach of the theorem. Ze’ev Rudnick and Ezra Waxman studied the variance of the number of prime angles in small sectors and proposed, on the evidence of a random-matrix model, how it should behave as the sector shrinks; their conjecture predicts departures from pure randomness in a specific range of widths. The discrepancy measured here is a single number per bound, and it is consistent with fluctuations that are smaller than random; whether it fits their model or reveals something else would take the computation to much larger bounds and to many more sector widths than are drawn here.

The question that started this — which way do the primes face — has a simple answer and a hard edge. Every way, evenly. And the evenness is finer than chance at every size anyone has looked, which nobody has yet explained.

The circle that decides

Seen from far enough back, this is the third time the same circle has answered a question about primes by turning it into geometry. The first rule decided which primes lie on a lattice circle, and the answer came from remainders modulo four. The descent showed that a rational point on the circle forces a lattice point, by a reflection that never mentions primes. Here the direction of the lattice point turns out to be a remainder too — a continuous one — and the evenness of primes among remainders, which Dirichlet proved for progressions, carries over to directions on the circle with the same proof in a new key.

That carrying-over is why Hecke’s characters became the template for much of twentieth-century number theory. Almost every equidistribution theorem about primes since — primes in progressions, in sectors, in the remainders a quadratic form allows, in the angles of elliptic curves — has the same skeleton: name the symmetry, write down its characters, build an L-function from each, and show that none of them vanishes where it would have to for a bias to survive. The wedge of points in the first figure is the simplest picture of what that skeleton proves. Every direction is visited, in proportion, by primes that were never told which way to point.

Shares its objects with

Essays that name at least two of the same things, and that neither author linked.

Named objects

A dashed tag is an object no other essay names yet.

Dirichlet theoremDiscrepancyEquidistributionGaussian integersLatticePrimesSums of two squares