After all this playing with the -function it is time to return to the overall objective of this whole exercise: counting prime numbers. The idea behind analytic number theory is that primes are unpredictable on the small scale, but actually surprising regular on the large scale. This is why we'll look at certain functions that behave pretty erratically when we look at every single value, but become smooth and "easy" to calculate once we "zoom out" and consider the global properties, the so-called asymptotic.

I've mentioned the function before which is defined as the number of primes not exceeding some real . (Never mind the overloading of the symbol for different and completely unrelated functions, constants, etc. It's been like that for ever, and always will be. Mathematicians are pretty stubborn.) If we can calculate exactly, we would have perfect information about the primes since the function counts the primes exactly. Theoretically. But as mentioned before, we are only interested in capturing the overall behaviour, forgetting "local" irregularities.

So, what does look like? Most of the time, it is just a flat line for most of the values when the count does not change as they are not primes. At every prime value it jumps up by one step. That's it.

Well, almost. It turns out that it's convenient to define the value of for primes as "half the step", i.e., the value of would be , is , and then takes the value . It doesn't matter asymptotically, but the arguments that follow will go more smoothly. Yet, this is quite inconvenient to write out every time, so I will drop it for most of time, but always implicitly assume that functions at values where the argument jumps are "smoothed out".

It is usually interesting to look at the density of a certain sequence, i.e., the proportion of all integers that are members of that sequence. In this case it means calculating . But already quite elementary arguments are sufficient to show that this value tends to zero. In other word, the density of the primes is zero. Now, in order to obtain a function that behaves more like we need to give the primes a sufficient weight. It is the nature of the Prime Number Theorem that the th prime is about . This means that we need to give each prime weight to obtain a function that behaves like . This function was first introduced by Pafnuty Chebyshev, is usually called , and formally defined as , where the sum runs over all primes not exceeding . Just for the sake of completeness, I will mention the closely related function that gives weight not only to primes, but also to prime powers .

Both functions and may seem a little artificial at first glance, but they are in fact very natural in the context of counting primes. It is probably best depicted by the fact that the Prime Number Theorem is equivalent to and . This relates to my earlier comment that we assign a certain weight to the primes in order to obtain a function with a positive density. Many equations including prime counting functions become more concise by writing them in terms of instead of .

To confuse things even further, we will need yet another prime counting function for our purposes. It is usually denoted and counts all the primes below plus *half* the prime squares plus a *third* of the prime cubes etc. How many numbers below are the perfect square of a prime? It may sound tricky to count these, but it's quite easy if we approach the problem from the other direction: How do we generate all prime squares not exceeding ? Well, we go through all the primes and take their square. We stop as soon as exceeds . In other words, we can generate a prime square for every prime below . And here's our answer! There are prime squares not exceeding . The same argument goes for cubes and higher powers. This gives us a neat formula for :

It is worth noting that this is actually a finite series. No matter how large you choose , the value will get smaller as the in the series increases, and will eventually drop below . Since there are no primes smaller than , the value of for that and all subsequent ones will be zero, effectively terminating the sum.

There's another way of expressing . The same way that can be expressed as a straightforward "counting sum"

which literally just means "count for each prime", we can write down the same for . How exactly do we count here? Well, for any prime , we count for the prime, for the square , for the cube , etc. Then we just add up everything:

The cool thing is that we can get the value of back from through a technique called *Möbius inversion*. It is actually not too difficult but slightly out of scope here, so let's be content for now that we can invert certain sums by means of the so-called Möbius function . This and similar inversion techniques would deserve an article on their own right, but for now without further ado, this is the inverted formula:

You may think: Big whoop! We wrote down a much more complicated function, just to find another complicated expression to get our initial object of study back, but haven't learnt anything new. The great news is that we can calculate to any precision we care with the aid of the -function and its zeros.

But that's the subject of the next article. (Am I getting better at my cliffhangers?)

## 2 thoughts on “Counting Primes Functionally”

Comments are closed.