(Thanks to Karl for the 2019 Easter egg idea :) Welcome to the 2019 Mathologer Christmas video. In this video we'll investigate

that famous and amazing formula over there PI over 4 is equal to 1 minus 1/3

plus 1/5 minus 1/7 and so on. It's usually called a Leibniz formula after

Gottfried Wilhelm Leibniz one of the genius inventors of calculus. Sadly, like

many other results in mathematics, the formula was not discovered by the

mathematician it's named after, at least not first of all. In this case, Leibniz's

formula was first discovered by the indian mathematician Madhava of

Sangamagrama in the 14th century, more than 200 years before Leibniz. Anyway

this formula is definitely very beautiful. At the same time it's very

mysterious. Think about it, pi is of course a circle thing to do with

conferences and diameters and stuff. On the other hand, our formula is stitched

together from the odd numbers, without a circle in sight anywhere.

However, and hardly anybody knows this, when you look hard enough you can find a

huge circle hiding within this iconic formula. The first time I stumble across

this wonderful connection was over 40 years ago in a book by mathematical

megastar David Hilbert and his colleague Stefan Cohn-Vossen. This book "Anschauliche Geometrie" (German)

or "Geometry and the imagination" in English is a popular

account of modern geometry. If you're not familiar with this book, definitely check

it out. An absolute must-read. In their book Hilbert and Cohn-Vossen show how

the Leibniz Madhava formula follows from the area formula of the circle. And the

key to the ingenious argument is a result known as Fermat's Christmas theorem.

What a great hook for a Christmas video, don't you think? Now before we get into

the details there's a feature of our formula that will be very important and

that I'd like you to keep in the back of your mind. In the Leibniz-Madhava

formula the denominators are one, three, five, seven, etc. that's just the odd

numbers. We can think of these numbers as being split into two classes

corresponding to the negative and the positive terms of the series. In the

following I'll call the green numbers one, five, nine etc. "good" and the

remaining odd numbers three, seven, eleven etc. "bad". You'll see why later. Okay, let's

start with the xy-plane, highlight all the points with integer coordinates to

make a lattice and draw a circle centered at the origin.

Now count the lattice points within the circle. That number will be approximately

the area of our circle. Why? Because each point is the center of a little unit

square and then the total area of the circle is approximately the sum of the

areas of those squares. So pi r squared the area of the circle is approximately

equal to N(r), the number of those lattice points. Does this look familiar?

Most of us would have done something like this in primary school: draw a

squiggly loop on grid paper and estimate the area within the loop by counting

the number of squares inside. Back to the circle on our grid, solving for pi

gives an approximation to our favorite number, there. In the example here the

radius is 7 and the number of points is 149 and 7 squared is 49. So we have pi is

approximately 149 divided by 49 which is equal to three point zero four zero eight

Well not a great approximation but not bad either. At least the leading

three is right there Okay can we do better? I can see you

nodding and yawning and so let's get on with it and zoom out. Now, choosing a

larger circle makes the blue area more circulars and then also results in a

better approximation of pi. Go again ... even better. Now pushing the radius r

to 1,000 gives an approximation correct to those first four famous decimals:

3.1415. And pushing r all the way out to infinity the approximate sign turns

into an equal sign. And that's a challenge for you: find a short proof

that we get equality in the limit. As always give you ideas in the comments.

What comes next? Well we're supposed to be heading for

the Leibniz Madhava formula. So if our circle lattice games are going to help

this has to happen by finding some other way to calculate the numbers N(r).

Okay, let's focus on one of the lattice points that one there yeah. The

coordinates of the lattice points are integers and a distance of the point

from the origin is less than or equal to the radius of the circle, right? And with

the Pythagoras that is staring at us in the diagram we can summarize all this

information like this: five squared plus three squared equal to d squared which

is less or equal to r squared. And in the case of this lattice point five squared

plus three squared equals 34 and of course r squared equals 49. This means

that one way to count the number of points in the circle is to do this: first

we list all the integers from 0 to 49 then for every number in our list we

figure out all the different ways to write this number as a sum of two

integer squares. Finally the total number of all these

different ways is the number we're after, the number of blue lattice points. To get

a feel for how this works, let's figure out the different ways to

write the first few numbers in our list as sums of two integer squares. Okay

0 is first. How many ways are there to write 0 as a sum of two integer squares?

Hmm well of course there's just one such way.

This equation corresponds to the origin the point with coordinates (0, 0). What

about 1? Well there's obviously just these four different ways, corresponding

to four of the lattice points. Next the number 2 can also be written as four

different sums, corresponding to four points. What about 3 how many ways?

Hmmm, actually, none! And then 4. There are also four ways again. For 5 there are

eight different ways, and so on. Figuring out the ways of writing integers as the

sums of integers squares has a long long history and I could actually spend a

couple of videos just talking about this topic. But for now just note that because

of the symmetry inherent in the diagram the number of ways of writing our

integers as a sum of two integer squares is always a multiple of 4: zero ways

4 ways, 8 ways, 12 ways, and so on. The one exception is 0

corresponding to the point in the middle of the diagram, which can be written in

only one way. Now remember the fact that I asked you to keep in the back of your

mind? Remember my way of splitting up the odd numbers into the good ones and the

bad ones? Well that was to prepare you for a

stunningly beautiful theorem. This theorem expresses the number of ways of

writing a positive integer as a sum of two integer squares in terms of ... the

good and the bad odd factors of that integer. For the moment I'll just

introduce and apply this theorem later after we've successfully chased down the

Leibniz-Madhava formula I'll tell you more about the theorem, including the

Christmas connection. Okay I'll tell you what the theorem says using the number

18 as an example. The odd factors of 18 are 1, 3 and 9, as you can see up there. 1

and 9 are good and 3 is bad. Now you simply go number of good ones minus

the number of bad ones and then you times the resulting number by 4. Then

this magical theorem says that the number you get this way is the number of

ways to write 18 as the sum of two integer squares. How pretty is that?

So for 18 we have two good factors and one bad factor, so 2 minus 1 that's 1,

times 4 that's 4. So there are exactly four different ways to write 18 as the

sum of two integer squares. Three challenges for you: first what are the 4 ways to

write 18 as a sum of two integer squares. Second how many different ways are there

to write the number 2020 as the sum of integer squares. Third find all those

ways of writing 2020. Anyway what a stunningly slick and beautiful theorem,

don't you agree? A real shame that so few people ever get

to learn about it. Hopefully that will change because of this video. But now

think about the theorem 4(good - bad) doesn't this already feel kind of "Leibnizy".

There's a telltale 4 at the top and at the bottom and the bad odd

numbers get subtracted from the good ones in both expressions. The plot is

definitely thickening. So what comes next? Well you've probably already guessed it.

We'll now calculate the number of lattice points using our 4(good - bad)

formula. For that let's return to the radius 7 circle. So what we have to

do is to calculus 4(good - bad) for each integer from 1 to 49, sum all

the numbers we get and then a final plus 1 for the point at the origin. Can we do

this in a systematic manner? Yep, easy peasy :) But to be able to isolate and

really appreciate a trick that will give us our mysterious pi formula, let's be

super systematic. Have a look at these good odds and bad odds vector tables.

The numbers from 1 to 49 are at the top, the good odd numbers are listed here and

the bad odd numbers are listed below. And the dots indicate who is a factor of who.

For example, this dot here indicates that the good 5 is a factor of 10. Pretty

straightforward, right? And now we just tally up. Start with 1 up there. The

number of green dots here minus the number of orange dots here, so that's 1

minus 0 which is 1. For 2 we get again 1 minus 0 equals 1. And for 3 we get 1

minus 1 so 0. And now continue all the way up to 49, adding up all those

differences gives 37. Then multiplying by 4 gives 148 plus 1 for a grand total of

149. And 149 is the number of lattice points we found earlier. Ok, now a

slightly more efficient way of calculating that critical number 37 is

to just first adding up all the green dots and then all the orange dots and

then subtracting orange from green. But now comes the trick. It turns out to be

much, much easier to calculate the green and orange totals by tallying row by row

instead of column by column as we've done so far. Those of you who've made it

through our recent monster Euler-Maclaurin video may remember that we

used a similar trick there.

Let's see how this works. How many green dots are in the first row. Well, shall

I make it a challenge? Obviously, 1 is a factor of every positive integer and so

there are 49 dots in the first row. Now our second good number is 5. How many

dots in that row? Well those dots are equally spaced which is nice, right,

corresponding to all the multiples of five below 49. So how many are there? Well

that's simply 49 divided by 5, rounded down. That's called the integer part of 49

divided by 5 and we denote it with square brackets around a fraction. For the next

row we get 49 divided by the next good number so the integer part of 49 divided

by 9, and so on. Time to wrap up the proof.

So the number of lattice points N(7) is four times the total number of

green dots minus the total number of orange dots plus one and with our new

way of tallying the goods and the bads this equation looks like this. But anyway

to make the bit in the brackets look more "Leibnizy", let's alternate the

positive and negative terms. Alright, now remember for this specific example

49 is just a square of the radius which is 7 and so the general

formula looks like this. Now, can you see it coming? I sure hope you do. Remember

how we got our approximation for pi. We simply divided N(r) by r-squared. So

let's divide both sides of the equation above by r-squared.

Now zoom are off to infinity and let's see what happens to all the fractions.

Okay we already know that the fraction on the left will exactly zoom to pi. What

about on the right? Well the first fraction is r squared over r squared

which is a nice simple one. What about this one? Well if there were no integer

part brackets there then again our square on

top and the one at the bottom would cancel leaving us with 1/3. And, in

fact, as r zooms off to infinity, the limit of this fraction is 1/3. You can

fill in the details in the comments, which shouldn't be too hard of a

challenge. Next fraction. Well if the previous fraction zooms to 1/3 then this

one zooms to ... well what? 1/5 of course. And so on. And that very last

fraction? Well, of course as r gets huge that fraction just saps to zero. And the

final tweak, just divided by 4 and we're done. Tada

and it's my Christmas present for you. Like it? So now you see, the Leibniz-

Madhava formula really is a circle thing. It just comes from the formula for the

area of a circle. Pretty amazing isn't it? Now to make the zooming bit of our proof

completely bulletproof we actually have to worry a little bit more about some

details that I glossed over. For the experts among you think Riemann

rearrangement theorem and how exactly the series we're dealing with here grows

as the radius tends to infinity. Not hard at all,

just a little bit fiddly. Anyway if you're interested in these details, i'll

link to the relevant pages from Hilbert and Cohn-Vossens beautiful book in

the description. Well we're not quite done yet. Of course I still owe you some

details of the 4(good - bad) theorem and I have to explain the Christmas

connection. Right?

Let's see what our 4(good - bad) theorem says about a prime number like

17. Well a prime number has only two factors, the good 1 and the prime

itself. So what if the prime is itself good, like in the case of 17? Then we

have good - bad equals 2 and so our theorem guarantees that every good prime

can be written as a sum of two integer squares. Right? On the other hand, if the

prime is bad like 11 and then good - bad will equal zero. So our theorem says that

bad primes cannot be written as a sum of two integer squares. And that's known

as Fermat's Christmas theorem: good primes can be written as sums of integer squares

and bad primes cannot. That's also why I labeled the odd numbers good and bad

earlier on. Now the Christmas in the name of this theorem is standard, although the

connection with Christmas is pretty flimsy. It solely derives from the fact that

Fermat wrote about this theorem in a letter to the mathematician Marin Mersenne

on Christmas Day in the year 1640. Still if you are a desperate Mathologer, like

me, looking for a Christmas hook, you take what you can get. And there's also twist

to the Christmas hook. Yes you guessed it Fermat's Christmas theorem is not Fermat's.

The theorem was actually first stated by the mathematician Albert Girard 15 years

earlier. And that's a picture of Girard there. Well actually it's not Girard,

it's the cartographer Jodocus Hondius which is what Google spits out when you

ask for Girard. In fact Google choosing some designated replacement when it can't

find the correct portrait seems to be just as common as theorems being named

after the wrong person and sadly, as for Madhava, no picture for Girard seems to

have survived. Anyway, neither Fermat nor Girard provided a proof of the theorem and

the first to publish one was Euler. Well it's always Euler, isn't it? Actually while

we're delaying proving the Christmas theorem it's worth mentioning another

reason why the theorem is now so famous. In 1990 the mathematician Don Zagier came

up with an absolutely incredible one-sentence proof of the Christmas

theorem. There it is, but good luck with that sentence. Figure it out and you're probably

ready to begin a PhD in math(s). Now, historically, the Christmas theorem

preceded our 4(good - bad) theorem. The 4(good - bad) is known as Jacobi's two

square theorem and, wonder of wonders, appears to actually have been first

proved by Carl Jacoi and, yes, that's Jacobi there. And now we'll prove the

Christmas theorem and Jacobi's theorem? No, I'm sorry, definitely not today. To

mathologerise these theorems and to make them truly accessible is very

tricky and is still work in progress. But if I can't give you the proofs yet

I'd like to finish today by at least mentioning a couple of easy and

beautiful ideas that will give you a feel for where these theorems come from.

The first thing to note is that the bad half of Fermat's Christmas theorem is

really, really easy. In fact, it's easy to show that not only the bad primes but in

fact all bad odd numbers cannot be written as the sum of two integer

squares. None of these guys up there can be written as the sum of two integer

squares. Since it's so easy to prove, let's do it. First, notice that every bad

odd number is of the form 4k+3 right 4 times 0 plus 3 is 3, 4 times 1

plus 3 is 7, and so on. On the other hand, the good odd numbers are of the form

4k+1. In other words, the good odd numbers are the integers that leave a

remainder of 1 when you divide them by 4 and the bad odd numbers leave a

remainder of 3. What other remainders are there on

division by 4? Well, of course 0 and 2 corresponding to even numbers. So every

integer is of one of these four types. Now let's see what types we get when we

square integers. Obviously the square of a type zero number

gives a type zero back again. And it's easy to see that squaring a type one

number also gives back a type one. Just expand, right? See the pattern?

So, now squaring a type two numbers gives back,... no not a type two :) Did I trick you?

Actually, squaring a type two number gives back a type zero, as you can also

easily check by expanding. And, finally, squaring a type three number gives back

a type one. So, in summary, an integer squared either gives type zero or type

one but then what are the possible types of a number that is a sum of two squares?

Well, effectively, you're adding a couple of zeros or ones, so the sum of two

squares might be of type 0, 1, or two, but there's no way to get to that 3.

In other words, no bad or integer can possibly written as a sum of two integer

squares. And that's the easy half of the famous Christmas theorem. Pretty easy,

right? What else is there easy to say about the proofs of our two theorems. Well,

not a lot, but one aspect worth highlighting is the identity up there.

That identity which was already known to the ancient Greeks is the glue that

holds the two theorems together. What this identity tells us is that if

we have two integers that are both the sum of two integer squares, then their

product is also a sum of two integer squares. You get the sense of how this

might work? Since all positive integers are products

of primes once we know exactly how the primes can

be written as sums of squares, there's some hope that this identity will allow

us to extend the prime number results to all integers and actually also count the

number of ways to represent integers as sums of two squares which is what

Jacobi's theorem is about. And this is indeed what happens. Of course, as usual the

devil is very much in the details. But I'll leave those devilish details

for a time in the hopefully not too distant future. The big devil killer that

I will want to use is the law of quadratic reciprocity. Some of you will

be aware of what a challenge that will be to mathologerise. Okay, and that's just

about it for today. Just one more thing. If you liked what I did today there's

also a really nice video by 3blue1brown in which he animates a circle

based proof of the famous solution of the Basel problem, that infinite pi

series over there. And while you're there maybe also check out Euler's original

solution which I cover in the video at the bottom. Okay and that's really all

for today and all for this year. See you in the new year, FrÃ¶hliche Weihnachten.

Actually, actually, one more final final thing promise. We recently hit 500 000

subscribers which i think is pretty amazing for a hardcore mathematics

channel. Anyway I think it's pretty cool and I would

like to thank you all for your interest and your support over the years.

I'm not at all money minded and so I've always avoided even thinking about

monetizing these videos. However, maybe next year is a good time to take

Mathologer to the next level and hire someone to assist with editing the

videos, preparing subtitles, etc. In preparation for this, I recently

monetized the videos by switching on the least annoying ads on YouTube

I also just put up a Patreon page. If you enjoy these videos and you can afford it

please consider taking out one of the memberships or making a one-time

donation via PayPal the links are in the description of the video.

And now once again, for real, bye for now and FrÃ¶hliche Weihnachten.