The strangeness of the prime numbers (Riemann, part 2 of n) — November 28, 2026

The strangeness of the prime numbers (Riemann, part 2 of n)

Approaching Riemann from another direction: well, why are we talking about the zeta function in the first place? Yes, we established that it might have something to do with the prime numbers. But…well, let’s talk about the primes for a second.

Someone, somewhere along the way—I think it was probably Terence Tao—mentioned that the primes act a little bit randomly, and a little bit deterministically. (Presumably Tao said it more intelligently.) In some sense, of course they’re deterministic: whether a number is prime is not the result of a coin toss. But at the same time, there doesn’t seem to be an easy algorithm that we could tell to “print the 5 millionth prime number.” There is an algorithm for that; I can give you a very stupid one. But as far as I know, there’s no quick way to generate the nnth prime. (The 5 millionth prime is 86,028,121, using that very stupid code.)

And it gets weirder. There’s a variant of the proof of the infinitude of primes that goes like this: suppose you tell me that you would like to find a sequence of numbers, none of which is prime (i.e., all of which are composite), that is 1000 integers long. I will give you that sequence. I won’t necessarily give you the earliest place where you’ll find 1000 composite numbers in a row, but I’ll give you a place where you can find it.

The way to start building this sequence is to note that 1000 factorial—which we abbreviate 1000!1000!, and which equals 1000 times 999 times 998 times ⋯ times 3 times 2 times 1—is divisible by every integer between 2 and 1000. Likewise, 1000!+21000! + 2 is divisible by 2, 1000!+31000! + 3 is divisible by 3, and so on up to 1000!+10001000! + 1000. That’s a sequence of 999 numbers. So if you want a sequence that’s exactly 1000 composite integers long, you’ll want to start with 1001!+21001! + 2 and continue up to 1001!+10011001! + 1001. So, in short, if you want a sequence of composite numbers that’s nn integers long, the sequence from (n+1)!+2(n+1)! + 2 through (n+!)!+n+1(n+!)! + n + 1 has you covered.

In other words, there are arbitrarily large gaps between the primes, if you look far enough.

On the other end, there’s the still outstanding twin prime conjecture, namely that there are infinitely many prime numbers separated by only 2. (For instance, 3 and 5 are twin primes, as are 5 and 7, 11 and 13, 17 and 19, and so forth. The question is whether there are infinitely many such pairs.) Mathematicians have proved that there are infinitely many primes separated by a gap of at most 246. If we can bring 246 down to 2, the twin prime conjecture is proved.

So on the one hand, the primes can be found as far apart as you want. On the other, there may well be infinitely many of them that are as close together as they could be. That makes them a little mysterious. So let’s try to get a sense of how prevalent the primes are, by just counting. And while we’re at it, we’ll skip to the punchline and add an approximation. And we’ll use the universal notation for “the number of primes less than or equal to nn,” namely π(n)\pi(n).

nn π(n)\pi(n) n/ln⁡(n)n / \ln(n) Relative error
10 5 4 25%
100 26 21 23.8%
1000 169 144 17.3%
10000 1230 1085 13.3%
100000 9593 8685 10.4%
1000000 78499 72382 8.5%
10000000 664580 620420 7.1%
100000000 5761456 5428681 6.1%

The prime-counting function seems to track n/ln⁡(n)n / \ln(n), where ln⁡(n)\ln(n) is the natural logarithm of nn. As nn gets larger, the relative error seems to decrease. Mathematicians back to Gauss, at least, speculated that the prime-counting function approaches n/ln⁡(n)n / \ln(n) as n→∞n \to \infty, in the sense that the ratio of π\pi to that approximation approaches 1. When this was finally proved, 30 years or so after Riemann, it was dubbed the Prime Number Theorem.

The Riemann Hypothesis falls out of his 1859 paper, which I’m given to understand proved a lot of results about the prime-counting function, including the “explicit formula”, which seems to connect a smoothed version of the prime-counting function to the log integral (which is similar to the n/ln⁡(n)n/\ln(n) approximation from above). The explicit formula includes the roots of the zeta function.

So that’s why we’re even slopping around in the zeta function to begin with: because the primes are a little random, but deterministic enough that people have hunted for a formula that counts them; and because the roots of the zeta function show up in the proof of the Prime Number Theorem.

That last fact alone, by the way, is mysterious and awe-inspiring on its own, if your eyes have been trained to spot it: if we count the number of primes below a certain threshold, and build an approximation to that count, we end up using the roots of the zeta function.

It’s weirder than that, actually: we’re not using the roots of the zeta function that I showed you in that earlier post; that zeta function was only defined for the real-valued argument ss. If we only allow ourselves to look at real numbers, the zeta function never equals zero—i.e., it has no roots. The way to make that function have some roots is to extend it to the complex plane, which is what Riemann did in his paper.

So somehow, to count the number of primes up to a threshold—which really seems like the simplest and most elementary of mathematical operations—we need to extend the zeta function to the complex plane, then find its roots. That’s extraordinary; I’m stunned that the human mind was able to take that leap.

In subsequent posts, I’ll map out how we get there—including, firstly, what people mean when they refer to the “trivial zeroes” of the zeta function. What makes a zero trivial? From what I can tell, the answer there doesn’t require too much complex-analytic machinery, so should be fairly easy to describe.

The Riemann Hypothesis (part 1 of n) — November 24, 2026

The Riemann Hypothesis (part 1 of n)

I’ve been thinking during idle moments over the last few months of how to convey to people why mathematics is beautiful. It’s a weird kind of beauty, and that’s been my main struggle: how to convey this weird kind of beauty to people who’ve learned it the wrong way and think it’s even a category error to talk about the beauty of some formulas they’ve had shoved down their throats.

I don’t have the self-confidence to think that this will actually convince anyone, but I’m going to keep trying. I’m going to start sort of in the middle, or maybe toward the end. The short form is that

  1. People have been talking about the Riemann Hypothesis lately. The fundamental object they’re talking about is this thing called the Riemann Zeta Function:

    ζ(s)=∑n=1+∞1ns \zeta(s) = \sum_{n=1}^{+\infty} \frac{1}{n^s}

  2. The zeta function is intimately connected to the prime numbers, by way of the “Euler product formula,” in a way that should be surprising.

  3. That feeling of surprise is central to (at least my experience of) mathematical joy, which is an under-discussed topic, and (again, at least in my experience) not usually part of the mathematics curricula that we all had in American schools.

  4. Leonhard Euler embodies a certain kind of mathematical experimentation that brings that joy front and center, if your eyes are trained to look for it.

I want to write this out in as much detail as I can without losing everyone, because it’s just interesting and beautiful.

Continue reading →
Studying math on my own: tips? — June 30, 2017

Studying math on my own: tips?

I have a basically limitless pile of papers to read, a large fraction of which (I’ve not counted) contain a heavy math element. To take one example basically at random: Stein’s paper on “The Inadmissibility Of The Usual Estimator For The Mean Of A Multivariate Normal Distribution”. I don’t really get that paper. In particular, I don’t have the intuition about the topic that I do about, say, Unix or even economics: I can’t come to the topic and consume the whole thing in big chunks, which I can understand as a unit; instead I’m groveling through it line by line, and maybe understanding one tree at a time while the forest remains unassaulted. My reading of mathematics is a lot like my reading of French, while my reading of other topics is fluid like my reading of English.

Backing up from academic papers: it’s been a long-term goal of mine to learn measure theory, which underlies probability theory. I have ever so many books that cover aspects of measure theory: this one, and also this one, not to mention this one, and of course we’d be remiss if we didn’t mention this one. They’re all good, but I find them all hard. To pick another random mathematics book off the shelf: Körner’s book on Fourier analysis is fantastic at the high level at which I’ve been able to understand it, but digging into the details has always felt to me like an impossible slog.

Is the answer no more complicated than

  1. go to a library with just those books (no phone, no laptop), a pad of paper, and a pen
  2. bang your head against the problem sets for hours and hours
  3. GOTO 1

? It’s always felt to me like, no matter how much I bang my head against them, I’m going to be unable to prove theorems. I wonder if that’s true, or if that’s just the wrong side of my brain talking. I wonder if it’s the side of my brain that Ira Glass mentioned when we saw him in Boston a while back; a canonical form of the quote seems to be the one here:

All of us who do creative work, we get into it because we have good taste. But there is this gap. For the first couple years you make stuff, it’s just not that good. It’s trying to be good, it has potential, but it’s not. But your taste, the thing that got you into the game, is still killer. And your taste is why your work disappoints you. A lot of people never get past this phase, they quit. Most people I know who do interesting, creative work went through years of this. We know our work doesn’t have this special thing that we want it to have. We all go through this. And if you are just starting out or you are still in this phase, you gotta know its normal and the most important thing you can do is do a lot of work. Put yourself on a deadline so that every week you will finish one story. It is only by going through a volume of work that you will close that gap, and your work will be as good as your ambitions. And I took longer to figure out how to do this than anyone I’ve ever met. It’s gonna take awhile. It’s normal to take awhile. You’ve just gotta fight your way through.

An unspoken part of this is that not everyone is able to do creative work at a high level. (And mathematics is certainly included within “creative work”). Something similar would have to be said about, say, basketball: I watched a lot of the Bulls during the Michael Jordan era, and I knew from quite early on that my playing basketball at that level was just not an option. Or maybe it was — maybe I just needed to put in the hours, hire the coaches, etc. But it would always be harder for me to reach that level than it would be for Jordan. If I put in 9 billion hours of work, maybe I could get where he got with the mythical 10,000 hours. Probably not, though. There I stood on this side of the chasm, and there he stood on the other, and nothing I did was going to get me to his side.

Obviously I’m closer to being a professional mathematician than I am to being a professional basketball player. I feel like I’ve got more inherent writing talent than I do inherent mathematical talent. This isn’t to say that I’m John McPhee, but writing comes to me more fluidly than mathematics does.

Anyway, so yeah: do I just go to the library with some books and let the rest happen naturally? An obvious alternative is to pay someone to sit by my side while I read books and do problem sets; here in Boston, anyway, we call this “college”. So do I go to this mythical “college” to learn some more math? Or do I adopt some good self-study methods and do it on my own? Or is there some better way to learn math on one’s own?

What should I learn this year? — January 13, 2017

What should I learn this year?

I feel like I should learn some subject that’s entirely new to me. I basically did that with behavioral economics a few years back, and I found that fun. Now I’d like to find some subject that’s really interesting, totally new to me, and hopefully somewhat off the beaten path. Behavioral economics, for instance, is rather overplayed in the public discourse. Sociology and anthropology, on the other hand, are probably underplayed: among the social sciences, they get the least treatment in mass media, and the least respect among the sort of technical folks who would laud economics. So sociology and anthropology would be good candidates. Maybe I should start with Weber (apart from The Protestant Ethic, which I read and which is a Bad book — a book that is Bad), since he seems to be a father of sociology. And maybe Durkheim?

What about other fields? Anyone have any suggestions on books I really ought to be reading, in subjects about which I know little?

As always, I’d also like to learn more math. I’m much less good at it than I’d like to be. I think writing code may be the right way to learn it, so I think I’ll try to take that avenue in. It’d be interesting to actually code up some crypto and primality-testing algorithms, for instance. I tried to code up the AKS algorithm, but I didn’t really understand why I was coding what I was coding. So a textbook of number theory or crypto, taught via programming examples, would be useful. Likewise for linear algebra and complex analysis. Maybe Coding The Matrix would be the way to go.

Open thread. Let me know what I should stuff into my brain this year!

Two math things — September 21, 2016

Two math things

  1. It’s a long-term goal of mine to understand the proof of the Prime Number Theorem. The PNT, for those who are unfamiliar, is that the number of primes less than or equal to N is approximately N/ln(N), with the approximation improving as N grows to infinity; the percent error of the approximation approaches zero as N grows. I found a really interesting paper that walks through a proof. (The paper won an award for math exposition.) I’ve only done a quick first read-through, but it seems interesting. On that first pass, I think I now get why we even bother with the von Mangoldt symbol. Baby steps. If anyone would like to read along with me, y’all are welcome to.

    One question I have is whether it’s mathematically impossible to find a function that exactly equals the number of primes less than or equal to a number. The N/ln(N) approximation is good, but it’s just an approximation with a known rate of error — and while the percent error drops to zero, the absolute error grows without bound. Is there a proof that a function which counts the exact number of primes less than N is impossible?

    (I could be more precise about this. Obviously the function which sums the number 1 over all primes p less than or equal to x is an exact function. But it’s obviously not what I’m looking for. There’s probably a formal way to describe exactly what I’m looking for it. It’s probably either “a function containing only a certain set of symbols” or “a function of at most O(log n)” or something.)

  2. If someone gives you the equation “ax = b”, you can solve that really easily with elementary algebra; the solution is x = b/a. Likewise if someone gives you an equation involving x-squared; the solution is the quadratic formula. The solutions get more and more complicated for x-cubed and the fourth power of x. There’s a theorem (Abel-Ruffini) which says that no solution using only addition, subtraction, multiplication, division, and root extraction (square roots, cube roots, etc.) is possible for the fifth power of x and higher in the general case. When I limit it to “the general case”, I mean that certain specific equations at higher powers may have solutions: x100-1=0 has the solution x=1. But the general equation ax5+bx4+cx3+dx2+ex+f=0 has no solution, nor do equations with higher powers.

    The question I’ve had for a while (apart from knowing enough Galois theory to know how to prove Abel-Ruffini) is what happens if you allow mathematical operations other than addition, subtraction, and the rest. What if you allow sines and cosines? Fourier series and their inverses? Bessel functions? Elliptic functions? The Wiki says that a certain kind of transformation turns the general quintic into a simpler quintic polynomial, which can then be solved using a Bring radical. Is the Bring radical the simplest function which can solve the general quintic?

    So then my first question is: what’s the simplest set of functions you can add to addition, subtraction, multiplication, and division, such that the general quintic has a solution in this augmented set?

Annals of not publishing blog posts fast enough — February 13, 2016

Annals of not publishing blog posts fast enough

I’ve been updating the code underlying the Supreme Court death calculator, with an emphasis on greater mathematical precision and increased code elegance. Meanwhile, Justice Scalia has died.

For the record, I would not have predicted this. If you look at the CDC life tables, and scroll to page 35 (“Table 14. Life table for non-Hispanic white males: United States, 2010”), then scroll a little further down, you’ll see that, of 100,000 non-Hispanic white males born in the United States, 53,857 will survive to their 79th birthday. Justice Scalia would have been 84.9 years old on Inauguration Day, 2021. Of those 53,857 who make it to their 79th birthday, 38,053 are still alive on their 84th birthdays; 34,567 are alive on their 85th. So if you count 84.9 as “84 years old”, he had a 29% chance of dying before the 2021 inauguration. If you count it as 85, the number rises to 35%. If you interpolate between those two probabilities, you get (duh) a number between 29% and 35%. So I would not have bet money on his death.

The probability of one or more Justices’ dying, independently, between now and Inauguration Day 2021 was in the 85+% range. The expected number of Justices who’d die was around 1.7. I’ll have to re-run the numbers now with only 8 Justices.

For the mathematical record (inspired by seeing the Boston Holiday Pops with my parents) — December 6, 2015
ESPPs: magical free money — November 23, 2014

ESPPs: magical free money

Akamai has an Employee Stock Purchase Plan, which I’ve tried very hard not to think of as magical free money. But I think it basically is. It works like this: you set aside some fraction of your after-tax paycheck, and every six months the company uses that money to buy the company’s own stock for you. There are some limits on how the ESPP can be structured: the company can give you the stock at a discount, but the discount can’t be any more than 15% off the fair market value (FMV); you can’t get more than $25,000 in stock (at FMV) per year; and Akamai (in keeping, apparently, with general practice) imposes a further limit, such that you can contribute at most 15% of your eligible compensation.

To see how great the return on this is, consider first a simplified form of an ESPP. You put some money in, then wait six months; the company buys the stock, and you sell it immediately. They gave it to you at a 15% discount, i.e., 85 cents on the dollar. So basically you take your 85 cents, turn around, and sell it for a dollar. That’s a 17.6% return (1/.85 ~ 1.176) in six months. To turn that into an annual rate, square it. That makes it a 38% annual return.

Introducing some more realism into the computation makes it even better, because your money isn’t actually locked up for six months. In practice, you’re putting away a little of your money with every paycheck. So the money that you put in at the start of the ESPP period is locked up for six months, but the money you put in just before the end of the period is locked up for no time at all. The average dollar is locked up for three months. So in exchange for three months when you can’t touch the average dollar, that dollar turns into $1.176. Annualized, that’s a 91.5% return.

Doing this in full rigor means accurately counting how long each dollar is locked up. A dollar deposited at the start is locked up for 6 months; a dollar deposited two weeks later is locked up for six months minus two weeks; and so forth. It looks like this:

End of pay period 0: You have $0 in the bank.

End of pay period 1: You deposit $1. Now you have $1.

End of pay period 2: You deposit $1, and you earn a rate r on the money that’s already in the bank. So now you have 1 + (1 + r) dollars in the bank.

End of pay period 3: You deposit $1. The 1 + (1 + r) dollars already in there earn rate r, meaning that they grow to (1 + (1 + r))(1 + r) = (1 + r) + (1 + r)2. In total you have 1 + (1 + r) + (1 + r)2.

In general, at the end of period n, you have 1 + (1 + r)2 + (1 + r)3 + … + (1 + r)n-1 in the bank. That simplifies nicely: at the end of period n, you have (1 – (1 + r)n)/(1 – (1 + r)), or (1/r) (-1 + (1 + r)n) dollars in the bank.

At the end of the n-th period, you get back (1/.85)n dollars for the n dollars that you put in. So what does r have to be so that you end up with n/.85 dollars when period n is over? You need to solve (1/r) (-1 + (1 + r)n) – n/.85 = 0 for r. Use your favorite root-finding method. I get r=0.02662976. That’s the per-period interest rate. (It’s also known as the Internal Rate of Return (IRR).) In our case it’s a 6-month ESPP period, with money contributed every two weeks, so there are about n=13 periods. So the return on your money is ~1.026613 in six months, or 1.026626 in a year. That comes out to about a 98% return. Which is, to my mind, insane.

The full story would be both somewhat better and somewhat worse than that. Somewhat better, in that the terms of our ESPP are even more generous: when it comes time to buy the stock, Akamai buys it for you at the six-months-ago price, or the today price, whichever is lower. So imagine you have $12,500 in the ESPP account, that the stock is worth $60 today, and that it was worth $40 six months ago. You get shares valued at $40 apiece, minus the 15% discount. So the company buys shares at .85*$40=$34. It can buy at most $12,500 in shares (at FMV), so it can buy floor(12500/40)=312 shares. Cool. Now you have 312 shares, which you can turn around and sell for $60, for a total of $18,720. That is, you put in $12,500, and you got out $18,720. Magic $6,220 profit.

The “somewhat worse” part is that you pay taxes on two pieces of that. First, you pay taxes on the discount that they gave you (since it’s basically like salary). Second, if you hold the stock for any period of time and pick up a capital gain, you pay tax on that; if you held the stock for less than a year, that’s short-term capital gains (taxed at your regular marginal rate), whereas if you hold for a year or more you pay long-term cap gains (15%, I believe).

I’ve not refined my return calculation to incorporate the tax piece, but I doubt it changes the story substantially. First, it’s hard for me to imagine that the taxes lower the rate of return from 98% down to, say, 15%. Second, any other investment (a house, stocks, bonds, a savings account) would also require you to consider taxes. And since the question isn’t “Is an ESPP good?” but rather “Is an ESPP better than the alternatives?”, I suspect that taxes would affect all alternatives equally. It strikes me that ESPP must win in a rout here — which would explain why the amount you can put in the ESPP is strictly limited; otherwise it really would be an infinite magical money-pumping machine.

While we’re talking about Fourier series — November 22, 2014

While we’re talking about Fourier series

(…as we were), does anyone have an intuition — or can anyone *point me to* an intuition — for why Fourier series would be so much more powerful than power series? Intuitively, I would think that very-high-order polynomials would buy you the power to represent very spiky functions, functions with discontinuities at a point (e.g., f(x) = -1 for x less than 0, f(x) = 1 for x >= 0), etc. Yet the functions that can be represented by power series are very smooth (“analytic“), whereas the functions representable by Fourier series can be very spiky indeed.

The intuition may be in Körner, but I’ve not found it.

This could lead me down a generalization path, namely: develop a hierarchy of series representations, with representations higher on the hierarchy being those that can represent all the functions that those lower on the hierarchy can represent, plus others. In this way you’d get a total ordering of the set of series representations. I don’t know if this is even possible; maybe there are some series representations that intersect with, but are not sub- or supersets of, other series representations. I don’t think I’ve ever read a book that treated series representations generally; it’s always been either Fourier or power series, but rarely both, and never any others. Surely these books exist; I just don’t know them.

And now, back to reading Hawkins.

One of the clearest things about measure theory I’ve ever read — October 12, 2014

One of the clearest things about measure theory I’ve ever read

Check out Terry Tao’s measure-theory book, starting with ‘let us try to formalise some of the intuition for measure discussed earlier’ on page 18, through to ‘it turns out that the Jordan concept of measurability is not quite adequate, and must be extended to the more general notion of Lebesgue measurability, with the corresponding notion of Lebesgue measure that extends Jordan measure’ on p. 18.

I’ve understood for some time that there’s a notion of “non-measurable set”, and that you want your definition of ‘measure’ to preserve certain intuitive ideas — e.g., that taking an object and moving it a few feet doesn’t change its measure. I didn’t understand that there was any connection between non-measurability and the axiom of choice. Tao’s words here are some of the first that have properly oriented me toward the problem that we’re trying to solve, and the origins of that problem to begin with.

My partner is taking a biostatistics course, which is reminding me of how much I loved this stuff at CMU. I’m inclined to find a course in measure theory around here. We have a university or two.