Today I’d like us to take a journey through randomness to show how emergent properties
of the unpredictable define our reality. We’ll take a look at how pi is hiding in all aspects
of randomness, and, since our universe is governed by quantum mechanics, conclude that
pi is literally everywhere. We will even see how we can approximate pi by simply flipping a coin.
I’d also like to explore how, by wielding chaos, our computers generate random numbers,
and what that might mean for alternate universes. I hope, by the end of the video, that we can
confidently answer the question: could pi be different in another universe?
First, I’d like to share with you an anecdote about
a 19th-century British mathematician, De Morgan.
De Morgan was discussing with a friend of his, an actuary, the probability that a certain
proportion of a group of people would be alive at a given time. He referenced an actuarial formula
involving pi, explaining that pi is the ratio of the circumference of a circle to its diameter.
Upon hearing this, the actuary exclaimed, “My dear friend! That must be a delusion;
what can a circle have to do with the number of people alive at a given time?”
Most of you will be familiar with De Morgan’s definition for pi, circumference divided by
the diameter. What you might not know, is that this isn't technically true in our universe.
Einstein's Theory of General Relativity, which relates the curvature of spacetime with the mass,
energy, and any momentum within it, shows us that Euclidean Space, as in space that isn’t curved,
can only ever be an approximation for our universe, since spacetime is curved everywhere.
If you were to measure this ratio of a circle anywhere in the universe,
you’d never truly get pi. This would be especially
noticeable where spacetime is curved more severely, such as near a black hole.
The problem lies with the method we're all taught. Defining pi this way assumes space
is perfectly Euclidean. Therefore it may seem like pi is a more theoretical construction that isn't
intrinsic to our universe. However, I'd like to show you how, by answering the Actuary's question,
pi does relate to our universe in a very beautiful, fundamental way.
To answer the Actuary’s question, let's begin by taking a walk.
Say we're standing somewhere, which we’ll label "0". Our walk will be controlled by flipping a coin:
if it is heads, we take a step forwards; if it is tails, we take a step backwards.
Every step, flipping the coin, and either moving +1 or -1.
How far away are we, from the start, on average, after, say, 10 flips of the coin? From our first
walk, we end up where we started, a distance of 0. It should be clear to see that on average we
actually don't make much progress at all, as we are equally likely to move in both directions;
but, how likely actually is it, that we flip the exact same amount of heads and tails,
for example, our second walk ended up at a distance of 4, since it had 4 more heads
than tails. From looking at our walks so far, we may estimate that after 10 flips, we end
up roughly 2 steps away, but let's generalise and consider the following question instead:
how far away are we from the start, on average, after n flips of the coin?
This random movement process is called a random walk, and can be characterized by
this diagram. In fact, this process shows up everywhere: for instance, the motion of
particles in a liquid or gas, called Brownian Motion, follows this same exact phenomenon.
You would have likely seen this before, without realising, in the form of a Galton Board.
The Galton Board is essentially lots of little beads taking random walks simultaneously. Instead
of flipping coins, the beads hit consecutive pegs, going either left or right at each one. The nice
thing about it is that you can clearly see not only where the beads end up, but also how likely
each destination is. However, for De Morgan, the key detail is the shape created at the bottom.
This shape is called the normal distribution, or the bell curve.
It was observed by 18th-century astronomers trying to analyse the orbits of celestial bodies.
It was initially dubbed the “Law of Frequency of Error”, because when performing their
calculations, they would need to take into account observational error: the law described how their
measurements would bunch around the average, and provided estimates for the chances of an error of
a given size. You should be able to draw parallels to our random walk game here - a huge error in
measurement is less likely to occur, just like us ending up far away from the start is less likely.
Adolphe Quetelet realised this was more than just an error law.
He recognised that it could be applied to almost anything:
human characteristics, crime, marriage - it was discovered that this shape was everywhere.
By now, the actuary should be able to see how the number of people alive at a given time
can relate to flipping a coin, which before he might not have believed possible.
But where is pi hiding? And would a different universe form a different curve?
We’ve asked a lot of questions, so let’s start answering all of them
To please the Actuary, and find pi, we will need to look deeper into the normal distribution.
The equation, e to the minus x squared is the fundamental shape of this curve.
Where e is simply a number, 2.718… an irrational, never-ending one similar to pi.
The shape is quite straightforward, minus infinity to plus infinity on the x-axis,
and 0 to 1 on the y-axis. I’d like us to find the area of this shape,
but this is a surprisingly difficult task! An incredible discovery, that we’ll see momentarily,
is that if we go one dimension higher, pi jumps out at us,
and with some high school maths, we’ll solve this problem with a very elegant solution.
To go one dimension higher, we’ll need to have not just one parameter, but two.
Our function will now depend on x and y, and will simply be f(x) times f(y),
from exponentiation laws, this simplifies to e to the minus x squared minus y squared.
Let’s visualise what’s going on here, It forms a three-dimensional normal distribution,
where we have x, y and z. From the second image, it should be clear to see that if we take a two-
dimensional slice anywhere, we will see a normal distribution. So the secret is to find the volume
of this shape, and then we can work out the area of our bell curve. But what’s the relationship? As
we are finding the volume, that is integrating, f(x) and f(y), which are identical functions,
we can simplify this to mean we are finding the area of just f(x), and then squaring,
therefore our volume will be equal to our area squared.
Now, are you ready to finally see how pi relates to everything we’ve seen so far in this video?
It’s truly beautiful. This three-dimensional normal distribution is constructed
by circles - infinitely many to be precise. So, to find the volume,
we will need to sum all of them up. We’ll say each circle has an infinitely small thickness, dz,
so really, they’ll be dics. How do we find the volume of a single disc?
Well that’s easy, it will be the area of a circle, pi r squared, multiplied by its thickness, dz.
We’ll need an equation for r. As each circle has a center (0, 0), the radius can be found using
trusty Pythagoras’ theorem, r squared will equal x squared plus y squared. If you recall earlier,
we simplified our 3D normal function to be z equals e to the minus x squared minus y squared.
Taking the natural logarithm of both sides, we get the natural log of z equals minus x
squared minus y squared. Rearranging gives x squared + y squared = negative natural log of z.
Therefore, we can say r squared equals negative natural log of z.
The equation for our discs now becomes pi times the negative natural log of z, dz.
To sum them up, giving us our volume, we’ll first thank Newton and Leibniz,
and then integrate. We’ll want to integrate from 0 to 1, as our graph has asymptotes at z equals 0,
and has a peak at (0, 0) where z equals 1. After tidying up, to integrate this, we’ll just need
just one other piece of help, integration by parts. This is where the integral of u dv
equals u times v minus the integral of v du. Here, we’ll say u is the natural log of z and dv is dz.
Differentiating gives us du equals 1 over z dz, and integrating dv gives v equals z.
Substituting this yields the volume is minus pi, multiplied by z times natural log of z,
from 0 to 1, minus the integral of this, which cancels to just give 1. Integrating 1 dz is
just z. So, after everything, we’re left with this. Plugging in 1 gives 1 times 0, which is 0,
minus 1. And then plugging in 0 gives: 0 for z, and we don’t care about this since
anything multiplied by 0 is 0, then minus 0. Therefore, this part evaluates to negative 1.
We can finally calculate our volume, it is minus pi times minus 1 - simply pi!
What a wonderful result. And if you remember, to find the area, all we have to do is square root.
So, the area under the normal distribution is the square root of pi.
The Actuary should think this is remarkable, as did I when I first heard this.
The hard part is over, now we know this, it’s easy to answer our previous questions.
We’ll first answer the question: how far away are you in the random walk after n flips of the coin?
I’d like to move programming here, but don’t get scared if you haven’t
coded before - I’ll be doing this in Python which is incredibly easy to read,
and I’ll make sure you understand everything as we go. Programming will prove very useful, as we
can easily perform our simulation of randomness. Flipping a million coins is rather time consuming.
The answer to the question comes from our previous result, the formula being:
the average distance equals the square root of 2N over pi, where N is the number of coin flips.
This one is a little bit more difficult, and certainly requires
a more abstract proof than the last. Feel free to research this however,
as it involves some really interesting mathematics, including the Gamma function.
Finding pi will require us to rearrange this formula,
as we can experimentally find the average distance, and therefore solve for pi. Pi
being the two times the number of flips, divided by the average distance squared.
I'll begin by importing numpy, which is a module in Python which let’s us do lots
of mathematics rather easily, and we’ll be using it to generate random numbers.
I’d like to break down this problem into three parts, generating random numbers,
finding average distance and then calculating pi.
We’ll begin by simulating what we did earlier, we’ll set the number of steps we take to be 10.
We’ll want our random numbers to be ones and negative ones,
to represent our heads and tails. To do this with numpy
we’ll use numpy.random.choice, and give the options 1 and negative 1.
Printing this shows us that every time we run it, we’ll get either a heads or a tails.
To generate how many we want, ten, we’ll select the size to be our variable steps.
We now get a random assortment of heads and tails.
Doing this one time is not enough: we will need to do thousands of runs to get a better average.
So we’ll make a new variable called runs, and set this initially to 5
and we’ll change our size to include this also.
Finding the average distance is pretty easy, if we just sum up each row here,
we’ll find out how many more of either heads or tails we got than the other.
We’ll also need to also take the absolute value to turn negative results positive.
To get the average, it’s quite straight forward, numpy has a function for that too.
Now we can simulate our experiment from earlier on a much larger scale.
Our estimation was somewhat right, when we guessed we’d roughly be 2 steps away, it seems
to be more like 2.4 something. And our formula states that if we do 2N, which in this case is 20,
divided by this average squared, we should get pi. And sure enough, it isn’t too far off.
We may suspect that only doing 10 flips isn’t enough, and that’d be right.
The number of flips interestingly links to Pascal's triangle. Unfortunately I won’t go
into too much detail here, but you can imagine each number of this triangle to
be the number of ways to get to it. For example, Before we flip a coin, we’re at zero, and there’s
only one way to be there. Then, when we flip our coin, heads moves us to plus one and tails moves
us to minus one. There’s only one way to get to each of them. However, on our second flip, to get
to zero again, we could have either flipped a heads then a tails, or a tails then a heads… two ways.
To get to minus two, we’d need to get two tails, and for plus two, two heads, each only having one
way to get there. This triangle continues forever, but if you were to plot a row of this triangle,
you’d see it somewhat looks like the normal distribution. As you go down further and further,
the approximation gets better and better. Picking the number of flips in this simulation
is exactly like choosing a row of the pascal's triangle to approximate the normal distribution,
the higher the number of steps, the lower the row, the better the approximation.
Let’s use 500 flips, as this gives a very good approximation, and instead do one million runs.
We’re easily getting within 1% of pi’s true value here.
And you can imagine if we use an infinite number of steps and runs, we would approach pi exactly.
Now I’d like to relate this to our universe, by doing something really quite extraordinary. In
this new file, pi from pi.py, I imported this huge text file containing a billion digits of pi.
I then split the digits of pi into sections 500 digits long. Instead of ones and minus ones,
I look for how many more even or odd digits there are compared to the other,
and then find the average across one hundred thousand sections. Would you look at that,
after performing the same calculation, it gets us pi too. Now, to link this to our universe:
as everything is governed by quantum mechanics, whereby a fundamental feature of this theory
is that nothing is certain, and instead events have probabilities. Are the digits of pi random,
truly random? We’ll, they stay the same no matter what method we use to calculate it,
so I’d argue that they are instead unpredictable, just like quantum mechanics says our universe is.
You can truly find pi in everything, and to really blow you mind, empty space is
full of quantum interactions of particles and antiparticles, which are unpredictable too.
You can’t escape pi in this universe. But what about a different one?
If a universe were truly not random, and entirely deterministic, could you then finally break free
from pi as we know it? Using this next piece of code, I’d like to argue that no, pi would dominate
in that universe too, and it has to do with the way we can generate pseudo random numbers.
Pseudo random numbers are those generated with deterministic equations.
Our computers can’t think randomly, but they can harness a thing called Chaos. The definition of
chaos is: a property of a complex system whose behaviour is so unpredictable as to appear random,
owing to great sensitivity to small changes in conditions…. I really dislike this definition.
Chaos appears in incredibly simple systems too. Take the equation 2x squared minus 1. In this piece of code,
I don’t generate any random numbers, nor import anything unpredictable either. If you’re curious,
I’m iterating values through this equation and looking at whether the digit in the 10th decimal
place is odd or even. From simplicity, we get unpredictability, we get pi.
No universe can escape chaos, every universe is unpredictable.
All of reality is forced to deal with pi, because life is inherently unpredictable.
So even though nothing seems certain, you can always count on pi being the same.
This video was inspired by 3Blue1Brown's Summer of Maths Exposition. As of recording, the deadline is tonight and
this video isn't exactly where I'd like it to be, but I'm hoping you enjoyed it anyway. There
is plenty I didn't get a chance to talk about, and some things which aren't as polished as I
would've liked. However, thanks to Grant, I got started, and posted my first video. Also, thank
you Ella Katz for helping with this one. I will hopefully be publishing many more in the future,
and at the moment the overarching series will most likely be called 'Manifestations of Mathematics'.
I am looking forward to also making extra videos, which will be more focused on programming,
where I can explore topics from my 'main' videos that I think deserve extra attention.
There were many, many things I had to leave out of this one,
but I’ll likely post a few short videos about some of them soon.
Thank you for watching and I look forward to learning with you again soon.