### Video Transcript

This is a video Iβve been excited to make for a while now. The story here braids together prime numbers, complex numbers, and π in a very
pleasing trio. Quite often in modern math, especially that which flirts with the Riemann zeta
function, these three seemingly unrelated objects show up in unison. And I wanna give you a little peek at one instance where this happens, one of the few
that doesnβt require too heavy a technical background.

Thatβs not to say that this is easy. In fact, this is probably one of the most intricate videos Iβve ever done, but the
culmination is worth it. What weβll end up with is a formula for π, a certain alternating infinite sum. This formula is actually written on the mug that Iβm drinking coffee from right now
as I write this. And a fun, but almost certainly apocryphal story is that the beauty of this formula
is what inspired Leibniz to quit being a lawyer and instead pursue math.

Now, whenever you see π show up in math, thereβs always gonna be a circle hiding
somewhere, sometimes very sneakily. So the goal here is not just to discover this sum, but to really understand the
circle hiding behind it. You see, there is another way that you can prove the same result that you and I are
gonna spend some meaningful time building up to, but with just a few lines of
calculus. And this is one of those proofs that leaves you thinking, βokay, I suppose thatβs
true,β but not really getting a sense for why or for where the hidden circle is. On the path that you and I will take though, what youβll see is that the fundamental
truth behind this sum and the circle that it hides is a certain regularity in the
way that prime numbers behave when you put them inside the complex numbers.

To start the story, imagine yourself with nothing more than a pencil, some paper, and
a desire to find a formula for computing π. There are countless ways that you could approach this. But as a broad outline for the plotline here, youβll start by asking how many lattice
points of the plane sit inside a big circle. And then that question is gonna lead to asking about how to express numbers as the
sum of two squares, which in turn is gonna lead us to factoring integers inside the
complex plane. From there, weβll bring in the special function named chi, which is gonna give us a
formula for π that at first seems to involve a crazy complicated pattern dependent
on the distribution of primes. But a slight shift in perspective is gonna simplify it dramatically and expose the
ultimate gold nugget. Itβs a lot, but good math takes time. And weβll take it step by step.

When I say lattice point, what I mean is a point π, π on the plane, where π and π
are both integers, a spot where the grid lines here cross. If you draw a circle centered at the origin, letβs say with radius 10, how many
lattice points would you guess are inside that circle? Well, thereβs one lattice point for each unit of area. So the answer should be approximately equal to the area of the circle, ππ squared,
which in this case is π times 10 squared. And if it was a really big circle, like radius 1000000, you would expect this to be a
much more accurate estimate, in the sense that the percent error between the
estimate ππ squared and the actual count of lattice points should get smaller.

What weβre gonna try to do is find a second way to answer the same question: how many
lattice points are inside the circle. Because that can lead to another way to express the area of a circle and hence
another way to express π. And so, you play and you wonder. And maybe, especially if you just watched a certain calculus video, you might try
looking through every possible ring that a lattice point could sit on.

Now if you think about it, for each one of these lattice points, π, π, its distance
from the origin is the square root of π squared plus π squared. And since π and π are both integers, π squared plus π squared is also some
integer. So you only have to consider rings whose radii are the square roots of some whole
number. A radius of zero just gives you that single origin point. If you look at the radius one, that hits four different lattice points. Radius square root of two, well that also hits four lattice points. A radius square root of three doesnβt actually hit anything. Square root of four, again, hits four lattice points. A radius square root of five actually hits eight lattice points. And what we want is a systematic way to count how many lattice points are on a given
one of these rings, a given distance from the origin, and then to tally them all
up.

And if you pause and try this for a moment, what youβll find is that the pattern
seems really chaotic, just very hard to find order under here. And thatβs a good sign that some very interesting math is about to come into
play. In fact, as youβll see, this pattern is rooted in the distribution of primes. As an example, letβs look at the ring with radius square root of 25. It hits the point five, zero since five squared plus zero squared is 25. It also hits four, three since four squared plus three squared gives 25. And likewise, it hits three, four and also zero, five. And whatβs really happening here is that youβre counting how many pairs of integers
π, π have the property that π squared plus π squared equals 25. And looking at the circle, it looks like thereβs a total of 12 of them.

As another example, take a look at the ring with radius square root 11. It doesnβt hit any lattice points. And that corresponds to the fact that you cannot find two integers whose squares add
up to 11. Try it! Now, many times in math, when you see a question that has to do with the 2D plane, it
can be surprisingly fruitful to just ask what it looks like when you think of this
plane as the set of all complex numbers. So instead of thinking of this lattice point here as the pair of integer coordinates
three, four, instead think of it as the single complex number three plus four
π. That way, another way to think about the sum of the squares of its coordinates, three
squared plus four squared, is to multiply this number by three minus four π. This is called its complex conjugate. Itβs what you get by reflecting over the real axis, replacing π with negative
π.

And this might seem like a strange step if you donβt have much of a history with
complex numbers. But describing this distance as a product can be unexpectedly useful. It turns our question into a factoring problem, which is ultimately why patterns
among prime numbers are gonna come into play. Algebraically, this relation is straightforward enough to verify. You get a three squared and then the three times minus four π cancels out with the
four π times three. And then, you have negative four π squared, which because π squared is negative one
becomes plus four squared.

This is also quite nice to see geometrically. And if youβre a little rusty with how complex multiplication works, I do have another
video that goes more into detail about why complex multiplication looks the way that
it does. The way that you might think about a case like this is that the number three plus
four π has a magnitude of five and some angle off of the horizontal. And what it means to multiply it by three minus four π is to rotate by that same
angle in the opposite direction, putting it on the positive real axis, and then to
stretch out by a factor of five, which in this case lands you on the output 25, the
square of the magnitude.

The collection of all of these lattice points π plus ππ, where π and π are
integers, has a special name. Theyβre called the Gaussian integers, named after Martin Sheen. Geometrically, youβll still be asking the same question. How many of these lattice points, Gaussian integers, are a given distance away from
the origin, like square root of 25? But weβll be phrasing it in a slightly more algebraic way. How many Gaussian integers have the property that multiplying by their complex
conjugate gives you 25? This might seem needlessly complex. But itβs the key to understanding the seemingly random pattern for how many lattice
points are a given distance from the origin. To see why, we first need to understand how numbers factor inside the Gaussian
integers.

As a refresher, among ordinary integers, every number can be factored as some unique
collection of prime numbers. For example, 2250 can be factored as two times three squared times five cubed. And there is no other collection of prime numbers that also multiplies to make 2250,
unless you let negative numbers into the picture, in which case you could just make
some of the primes in this factorization negative. So really, within the integers, factorization is not perfectly unique. Itβs almost unique with the exception that you can get a different-looking product by
multiplying some of the factors by negative one.

The reason I bring that up is that factoring works very similarly inside the Gaussian
integers. Some numbers, like five, can be factored into smaller Gaussian integers, which in
this case is two plus π times two minus π. This Gaussian integer here, two plus π, cannot be factored into anything smaller, so
we call it a Gaussian prime. Again, this factorization is almost unique. But this time, not only can you multiply each one of those factors by negative one to
get a factorization that looks different. You can also be extra sneaky and multiply one of these factors by π and then the
other one by negative π. This will give you a different way to factor five into two distinct Gaussian
primes.

But other than the things that you can get by multiplying some of these factors by
negative one or π or negative π, factorization within the Gaussian integers is
unique. And if you can figure out how ordinary prime numbers factor inside the Gaussian
integers, that will be enough to tell us how any other natural number factors inside
these Gaussian integers. And so here, we pull in a crucial and pretty surprising fact. Prime numbers that are one above a multiple of four, like five or 13 or 17, these
guys can always be factored into exactly two distinct Gaussian primes. This corresponds with the fact that rings with a radius equal to the square root of
one of these prime numbers always hit some lattice points. In fact, they always hit exactly eight lattice points, as youβll see in just a
moment.

On the other hand, prime numbers that are three above a multiple of four, like three
or seven or 11, these guys cannot be factored further inside the Gaussian
integers. Not only are they primes in the normal numbers, but they are also Gaussian primes,
unsplittable, even when π is in the picture. And this corresponds with the fact that a ring whose radius is the square root of one
of those primes will never hit any lattice points.

And this pattern right here is the regularity within prime numbers that weβre gonna
ultimately explain. And in a later video, I might explain why on earth this is true. Why a prime numberβs remainder when divided by four has anything to do with whether
or not it factors inside the Gaussian integers, or, said differently, whether or not
it can be expressed as the sum of two squares? But here and now, weβll just have to take it as a given. The prime number two, by the way, is a little special because it does factor. You can write it as one plus π times one minus π. But these two Gaussian primes are a 90-degree rotation away from each other. So you can multiply one of them by π to get the other. And that fact is gonna make us wanna treat the prime number two a little bit
differently for where all of this stuff is going. So just keep that in the back of your mind.

Remember, our goal here is to count how many lattice points are a given distance away
from the origin. And doing this systematically for all distances, square root of π, can lead us to a
formula for π. And counting the number of lattice points with a given magnitude, like square root of
25, is the same as asking how many Gaussian integers have the special property that
multiplying them by their complex conjugate gives you 25. So hereβs the recipe for finding all Gaussian integers that have this property.

Step one, factor 25, which inside the ordinary integers looks like five squared. But since five factors even further as two plus π times two minus π, 25 breaks down
as these four Gaussian primes. Step two, organize these into two different columns, with conjugate pairs sitting
right next to each other. Then, once you do that, multiply whatβs in each column. And youβll come out with two different Gaussian integers on the bottom. And because everything on the right is a conjugate with everything on the left, what
comes out is gonna be a complex conjugate pair, which multiplies to 25. Picking an arbitrary standard, letβs say that the product from that left column is
the output of our recipe.

Now, notice there are three choices for how you can divvy up the primes that can
affect this output. Pictured right here, both copies of two plus π are in the left column. And that gives us the product three plus four π. You could also have chosen to have only one copy of two plus π in this left column,
in which case the product would be five. Or, you could have both copies of two plus π in that right column, in which case the
output of our recipe wouldβve been three minus four π. And those three possible outputs are all different lattice points on a circle with
radius square root of 25. But why does this recipe not yet capture all 12 of the lattice points?

Remember how I mentioned that a factorization into Gaussian primes can look different
if you multiply some of them by π or negative one, negative π. In this case, you could write the factorization of 25 differently, maybe splitting up
one of those fives as negative one plus two π times negative one minus two π. And if you do that, running through the same recipe, it can affect the result. Youβll get a different product out of that left column. But the only effect that this is gonna have is to multiply that total output by π or
negative one or negative π. So as a final step for our recipe, letβs say you have to make one of four
choices. Take that product from the left column and choose to multiply it by one, π, negative
one, or negative π, corresponding to rotations that are some multiple of 90
degrees. That will account for all 12 different ways of constructing a Gaussian integer whose
product with its own conjugate is 25.

This process is a little complicated. So I think the best way to get a feel for it is to just try it out with more
examples. Letβs say, instead, we were looking at 125, which is five cubed. In that case, we would have four different choices for how to divvy up the prime
conjugate pairs into these two columns. You can either have zero copies of two plus π in the left column, one copy in there,
two copies in there, or all three of them in that left column. Those four choices multiplied by the final four choices of multiplying the product
from the left column by one or by π or negative one or negative π would suggest
that there are a total of 16 lattice points at distance square root of 125 away from
the origin.

And indeed, if you draw that circle out and count, what youβll find is that it hits
exactly 16 lattice points. But what if you introduce a factor like three, which doesnβt break down as the
product of two conjugate Gaussian primes? Well, that really mucks up the whole system. When youβre divvying up the primes between the two columns, thereβs no way that you
can split up this three. No matter where you put it, it leaves the columns imbalanced. And what that means is that when you take the product of all of the numbers in each
column, youβre not gonna end up with the conjugate pair. So for a number like this, three times five cubed, which is 375, thereβs actually no
lattice point that youβll hit. No Gaussian integer whose product with its own conjugate gives you 375.

However, if you introduce a second factor of three, then you have an option. You can throw one three in the left column and the other three in the right
column. Since three is its own complex conjugate, this leaves things balanced, in the sense
that the products of the left and right columns will indeed be a complex conjugate
pair. But it doesnβt add any new options. Thereβs still gonna be a total of four choices for how to divvy up those factors of
five, multiplied by the final four choices of multiplying by one, π, negative one,
or negative π. So just like the square root of 125 circle, this guy is also gonna end up hitting
exactly 16 lattice points.

Letβs just sum up where we are. When youβre counting up how many lattice points lie on a circle with a radius square
root of π, the first step is to factor π. And for prime numbers like five or 13 or 17 which factor further into a complex
conjugate pair of Gaussian primes, the number of choices they give you will always
be one more than the exponent that shows up with that factor. On the other hand, for prime factors like three or seven or 11, which are already
Gaussian primes and cannot be split, if they show up with an even power, you have
one and only one choice with what to do with them. But if itβs an odd exponent, youβre screwed. And you just have zero choices. And always, no matter what, you have those final four choices at the end.

By the way, I do think that this process right here is the most complicated part of
the video. It took me a couple times to think through that, βYes! this is a valid way to count
lattice points.β So donβt be shy if you wanna pause and scribble things down to get a feel for it.

The one last thing to mention about this recipe is how factors of two affect the
count. If your number is even, then that factor of two breaks down as one plus π times one
minus π. So you can divvy up that complex conjugate pair between the two columns. And at first, it might look like this doubles your options, depending on how you
choose to place those two Gaussian primes between the columns. However, since multiplying one of these guys by π gives you the other one, when you
swap them between the columns, the effect that that has on the output from the left
column is to just multiply it by π or by negative π. So thatβs actually redundant with the final step, where we take the product of this
left column and choose to multiply it either by one, π, negative one, or negative
π. What this means is that a factor of two, or any power of two, doesnβt actually change
the count at all. It doesnβt hurt, but it doesnβt help.

For example, a circle with radius square root of five hits eight lattice points. And if you grow this radius to square root of 10, then you also hit eight lattice
points. And square root of 20 also hits eight lattice points, as does square root of 40. Factors of two just donβt make a difference. Now whatβs about to happen is number theory at its best. We have this complicated recipe telling us how many lattice points sit on a circle
with radius square root of π. And it depends on the prime factorization of π. To turn this into something simpler, something we can actually deal with, weβre gonna
exploit the regularity of primes that those which are one above a multiple of four
split into distinct Gaussian prime factors, while those that are three above a
multiple of four cannot be split.

To do this, letβs introduce a simple function, one which Iβll label with the Greek
letter π. For inputs that are one above a multiple of four, the output of π is just one. If it takes in an input three above a multiple of four, then the output of π is
negative one. And then on all even numbers, it gives zero. So if you evaluate π on the natural numbers, it gives this very nice cyclic pattern:
one, zero, negative one, zero, and then repeat indefinitely. And this cyclic function π has a very special property. Itβs whatβs called a multiplicative function. If you evaluate it on two different numbers and multiply the results, like π of
three times π of five, itβs the same as if you evaluate π on the product of those
two numbers, in this case π of 15. Likewise, π of five times π of five is equal to π of 25. And no matter what two natural numbers you put in there, this property will hold. Go ahead; try it if you want.

So for our central question of counting lattice points in this way that involves
factoring a number, what Iβm gonna do is write down the number of choices we have,
but using π in what at first seems like a much more complicated way. But this has the benefit of treating all prime factors equally. For each prime power, like five cubed, what you write down is π of one plus π of
five plus π of five squared plus π of five cubed. You add up the value of π on all the powers of this prime up to the one that shows
up inside the factorization.

In this case, since five is one above a multiple of four, all of these are just
one. So this sum comes out to be four, which reflects the fact that a factor of five cubed
gives you four options for how to divvy up the two Gaussian prime factors between
the columns. For a factor like three to the fourth, what you write down looks totally similar: π
of one plus π of three, on and on up to π of three to the fourth. But in this case, since π of three is negative one, this sum oscillates. It goes one minus one plus one minus one plus one. And if itβs an even power, like four in this case, the total sum comes out to be one,
which encapsulates the fact that there is only one choice for what to do with those
unsplittable threes. But if itβs an odd power, that sum comes out to zero, indicating that youβre
screwed. You canβt place that unsplittable three.

When you do this for a power of two, what it looks like is one plus zero plus zero
plus zero, on and on, since π is always zero on even numbers. And this reflects the fact that a factor of two doesnβt help and it doesnβt hurt. You always have just one option for what to do with it. And as always, we keep a four in front to indicate that final choice of multiplying
by one, π, negative one, or negative π. Weβre getting close to the culmination now. Things are starting to look organized. So take a moment, pause and ponder. Make sure everything feels good up to this point.

Take the number 45 as an example. This guy factors as three squared times five. So the expression for the total number of lattice points is four times π of one plus
π of three plus π of three squared times π of one plus π of five. You can think about this as four times the one choice for what to do with the threes
times two choices for how to divvy up the Gaussian prime factors of five. It might seem like expanding out this sum is really complicated, because it involves
all possible combinations of these prime factors, and it kind of is. However, because π is multiplicative, each one of those combinations corresponds to
a divisor of 45. I mean, in this case, what we get is four times π of one plus π of three plus π of
five plus π of nine plus π of 15 plus π of 45.

And what youβll notice is that this covers every number that divides evenly into 45,
once and only once. And it works like this for any number. Thereβs nothing special about 45. And that to me is pretty interesting, and I think wholly unexpected. This question of counting the number of lattice points at distance square root of π
away from the origin involves adding up the value of this relatively simple function
over all the divisors of π.

To bring it altogether, remember why weβre doing this. The total number of lattice points inside a big circle with radius π
should be about
π times π
squared. But on the other hand, we can count those same lattice points by looking through all
of the numbers π between zero and π
squared and counting how many lattice points
are at distance square root of π from the origin. Letβs go ahead and just ignore that origin dot with radius zero. It doesnβt really follow the pattern of the rest. And one little dot isnβt gonna make a difference as we let π
grow towards
infinity.

Now, from all of this Gaussian integer and factoring and π function stuff that weβve
been doing, the answer for each π looks like adding up the value of π on every
divisor of π and then multiplying by four. And for now, letβs just take that four and put it in the corner and remember to bring
it back later. At first, adding up the values for each one of these rows seems super random,
right? I mean numbers with a lot of factors have a lot of divisors, whereas prime numbers
will always only have two divisors.

So it initially seems like you would have to have perfect knowledge of the
distribution of primes to get anything useful out of this. But if, instead, you organize these into columns, the puzzle starts to fit
together. How many numbers between one and π
squared have one as a divisor? Well, all of them. So our sum should include π
squared times π of one. How many of them have two as a divisor? Well, about half of them, so that would account for about π
squared over two times
π of two. About a third of these rows have π of three. So we can put in π
squared divided by three times π of three.

And keep in mind weβre being approximate, since π
squared might not perfectly divide
two or three. But as π
grows towards infinity, this approximation will get better. And when you keep going like this, you get a pretty organized expression for the
total number of lattice points. And if you factor out that π
squared and then bring back the four that needs to be
multiplied in, what it means is that the total number of lattice points inside this
big circle is approximately four times π
squared times this sum. And because π is zero on every even number and it oscillates between one and
negative one for odd numbers, this sum looks like one minus one-third plus a fifth
minus one-seventh, and so on.

And this is exactly what we wanted! What we have here is an alternate expression for the total number of lattice points
inside a big circle, which we know should be around π times π
squared. And the bigger π
is, the more accurate both of these estimates are. So the percent error between the left-hand side and the right-hand side can get
arbitrarily small. So divide out by that π
squared, and this gives us an infinite sum that should
converge to π. And keep in mind, I just think this is really cool. The reason that this sum came out to be so simple, requiring relatively low
information to describe, ultimately stems from the regular pattern and how prime
numbers factor inside the Gaussian integers.

If youβre curious, there are two main branches of number theory: algebraic number
theory and analytic number theory. Very loosely speaking, the former deals with new number systems, things like these
Gaussian integers that you and I looked at and a lot more. And the latter deals with things like the Riemann zeta function or its cousins,
called πΏ functions, which involve multiplicative functions like this central
character π from our story. And the path that we just walked is a little glimpse at where those two fields
intersect. And both of these are pretty heavy-duty fields with a lot of active research and
unsolved problems. So if all this feels like something that takes time to mentally digest, like thereβs
more patterns to be uncovered and understood, itβs because it is and there are!