This series of articles shows off a bunch of different prime counting functions that work in ways you're likely unfamiliar with.
There'll be lots of intriguing animating graphs, animations, and runnable JavaScript code.
The different prime counting functions are simple to tinker with, so they can hopefully serve as a springboard for other experiments, and they also introduce a lot of interesting number theory along the way.
Although I'll do my best to make them work on phones, the interactive graphs really, really benefit from a larger screen.
These articles are in the form dialogues between unnamed voices.
I accept this is a bit, well, unusual. But whether you're into math, animation, programming, or just intellectually curious, I hope you find it engaging.
Okay, let me begin...
I want you to watch something and then hazard a guess as to what it represents.
What's that?
It's the idea captured in this animation.
I... don't know. Is it an organic molecule, maybe?
Not an unreasonable guess. But no; actually, if you understand how to interpret the counts of these different colored circles in the graph, this is actually counting prime numbers.
Wait, really? Primes?
Really. In fact, follow along, and I'll walk through exactly how this works. There's a bunch of different styles of this idea that count primes in subtly different ways, all of which lead to different important number theory ideas. I find these formulas endlessly fascinating, so I hope to get across why I do.
Huh. Fine. Can you say what's noteworthy about these formulas, aside from their apparently ability to make animations?
Well, they're easy to play with and fiddle with. They are, in a word, quite tidy. They're well-suited to experimentation in common programming languages, as well as with basic graph plotting tools. So that's what I want to work through here in these essays.
Nearly everything demonstrated here will have real-time interactive graphs and snippets of JavaScript code, too. These tools are all intended to help explore these formulas, like the following interactive graph does:
Make sure to tap the buttons to see the graph refocus itself.
That does seem like a nice bit of interactivity. Are these formulas drawn from some specific reference?
Well, let me hold off on that question for a bit, and say instead that most of these formulas, or at least their roots before I manipulate them, will have direct connections to forms of $\log \zeta(s)$, the logarithm of the Riemann zeta function.
Meaning they correspond to the ideas you'd find in any good analytic number theory textbook, then?
Exactly, yes. But the lens here will be a bit unusual. It will be, if you can tolerate a bit of jargon, something like a discrete, partial sums approach instead, leaning heavily on simple functions and a lot of recursion.
Part of the magic of analytic number theory is that introduces lots of powerful, complicated ideas from rich fields like complex analysis and Fourier analysis to the study of prime numbers and other related topics.
Hence the name.
Right. Those fields are fascinating and interesting, certainly worthy of study, but they're all daunting. And they also present a serious barrier to exploration with normal programming languages.
Ah, true.
There's actually a lot about the distribution of primes that can be seen, done, and played with through simple discrete methods that work nicely with programming languages. A lot of interesting things can be explored without introducing the extra intellectual requirements of calculus, complex analysis, and questions of convergence. So that's what I will strive to do here.
Can you give a road map here? What kinds of prime counting variations will be explored in this gallery?
First, an easy approach is to take the core recursive definition, apply a helper function, and see how the function changes. So I'll do that with five families of such functions. You can see some big, fascinating changes for a tiny amount of work, and doing this connects to a few important topics in number theory along the way.
Okay.
With a reasonable number theory background, you might find the next section more surprising and captivating. I'll introduce a bit of calculus, and then we can explore approximation, estimating roughly how many primes there should be. We'll explore a few different approaches to connecting the weighted count of prime powers to the logarithmic integral using the core recursive form. I hope by the time I'm done you find this particular style of connection quite natural and compelling.
Fine. Anything else?
Yes. There's another style of recursive form I'll introduce later that exploits some key symmetries. And then there will be a few more miscellaneous variations at the end, too, just to round things out.
Good enough. But let's move on.