on
Life of Pi, and.. Infinity
Well, this ain’t gonna be about the great Ang Lee movie Life of Pi (2012), I mean, sure, the protagonist’s name “Pi” was indeed named after the greek letter π, but this post was actually inspired by Pi Day, March 14 aka 3/14, otherwise I probably won’t be this prolific to write another post (twice a week might be too many!).
So what is this π? In short, we all know that it’s the mathematical constant that represents the ratio of a circle’s circumference to its diameter, with the value of:
3.141592653589793238462643383279…
Believe it or not, I actually manually typed all the above digits by heart. Back in the days, I used to be able to recite far more digits, probably close to 100 even. Unfortunately I don’t have Sheldon Cooper’s eidetic memory, so that’s how much stayed in my memories as I grew older. I did a quick lookup online, that’s actually a correct recollection! Woohoo!
I love the thriller drama Person of Interest, in fact I might’ve watched the entire series more than once. The π was referenced many times by the show, one of which I quote from Fandom:
Finch impersonates a high school teacher to approach their next number, a teenager attending this school. He lectures to the class on how π is assumed to contain any finite sequence of digits within its never-ending decimal sequence, and stresses the fact that “now, whatever [they] do with this information, will be entirely up to [the student]”.
That’s so profound. You can actually find your social insurance number, date of birth, phone number, in fact, any finite sequence of digits in π’s infinite digits, as long as you search further enough1. But if a girl at a bar tells you her phone number is the last 7 digits of π, I think you should take that as a no. :D
I’ve found a website that visualizes searches for birthdays in π for you. You can input your birthday in the format of your choice, for instance, let’s say a person was born on December 31, 1999. I just did a search on the website for 19991231
, and it says it’s found at 1,012,191-th
digit in π:
Isn’t this fascinating?
On that note, I’d like to ramble a bit about the nature of π, or more on how little we human race know about it really. So π is what we call, an irrational number
. To understand it, we’d have to know what a rational number is first.
Rational Number
Rational numbers are, in short, the numbers that can be represented by quotient or fraction p/q of two integers, a numerator p and a non-zero denominator q, when p and q are relatively prime / coprime.
A fraction of such number, when converted to decimal expansion, either terminates after a finite number of digits, or eventually begins to repeat the same finite sequence of digits over and over.
An example for the finite would be 1/2
, which is 0.5
. Or 2/1
, which is 2.0
.
As for the other case, an example would be 1/3
, which is 0.33333..
to the infinity. Or 5/11
, which is 0.45 45 45 45 45..
. There’s always a repeated pattern here.
Back in junior high, I actually asked my math teacher this question:
We know
1/3 * 3 = 1
, and1/3 = 0.33333...
, so by the laws of equation, theleft * 3
should equal toright *3
. We know1/3 * 3 = 1
, but on the right side, shouldn’t0.333... * 3
be equal to0.999...
, and1
will always be greater than0.999...
by an endlessly small margin?
My math teacher applauded me for my curiosity and said that was a great question. But he didn’t answer directly other than saying when I learn more about mathematics in the future, I’d understand that 1 = 0.999...
. I didn’t really buy that answer and secretly thought I had single-handedly discovered a mathematical paradox that my own teacher couldn’t even explain, which of course, was debunked when I learned advanced mathematics in college. To this, I owe him an apology for being a smart ass.
So a quick explanation of my teenager question via the limit of a series, by a 2021 Xiaofeng is:
You can actually apply this approach in converting 0.45 45 45 45 45..
to 5/11
, or other decimal expansions that have a repeated pattern to fractions.
You can also fact-check my steps on an online solver by putting in the following code (it’ll get rendered to a proper formula):
9\cdot \lim _{x\to \infty \:}\sum _{n=1}^{\infty \:}\:\left(\frac{1}{10}\right)^n
See? Mathematicians had that worked out a long time ago!
Irrational Number
Why is it called irrational number
? There’s actually a story behind it.
It was dated back to ancient Greece. Pythagoras, who is best known for The Pythagorean Theorem2 in the western world, had claimed all numbers in life can be represented by ratios of integers, i.e. are all rational numbers
as explained in last section.
But one of his proteges, Hippasus, was able to deduce that the square root of 2 can’t be represented by a ratio of rational numbers, by a beautiful contradiction proof, which I still remember vividly to this day:
The Proof by Contradiction
In a right triangle, the sum of the areas of the two squares on the legs (a and b) equals the area of the square on the hypotenuse (c), so what if a == b?
-
In that case, c2 = a2 + a2 = 2 * a2
-
Let a = 1, then we have c2 = 2 * 12 = 2
-
Say if c were indeed rational, we’d have c = p/q, where p and q are coprime, that is, no common factors other than 1
-
Then we have (p/q)2 = 2, i.e. p2 = 2 * q2
-
So p2 is an even number, then p must be an even number too cuz an odd number times itself is still odd
-
Let p = 2 * y since it’s even. So based on step 4, (2*y)2 = 2 * q2, i.e. q2 = 2 * y2
-
So q2 must be even then, and so is q
- Wait, both p and q are even now? Then they have at least one common factor of 2.. which is against step 3
- Contradiction found, so c can’t be in the form of p/q to begin with
QED!
Of course nowadays, we know the (positive) square root of 2 is an irrational number with value of:
1.41421356237…
So that’s where the name irrational
came from. Greek mathematicians termed this ratio of incommensurable magnitudes alogos
, or inexpressible.
Kudos for Hippasus for discovering this nearly 25 centuries ago! Legend has it that he was exiled and later thrown overboard to the sea by his fellow Pythagoreans, for discovering this “outrageous” irrational
number. :(
π, just like square root of 2 here, is an irrational number than cannot be converted to a ratio by integers.
To Infinity and Beyond
So rational numbers and irrational numbers together make up what we known as real numbers
. Why the term real
you ask? Cuz y’all mad mathematicians clearly weren’t satisfied with the numbers they had seen available then, so they had to invent these imaginary numbers
, also known as complex numbers
. That is, to resolve of the question of: what is the square root of -1
, which we all know that no real
number is, since the square of any real number is greater than or equal to zero. So the mathematicians came up with an imaginary number i
that makes this equation valid:
i2 = -1
You might wonder why? Why did mathematicians do that? To answer that, you’d actually need to pick up some more advanced math theories. It seems like a useless toy theory, but in reality, it’s actually being widely used our daily life, and is essential one might say. Ask BC Hydro analysts - I believe they can tell you how important it is in analyzing electricity!
I’m a bit ashamed to admit that, as much as I write code for a living nowadays, I used to study mathematics for 6 years as a college and graduate school major (#washedupmathematician). While I couldn’t make a career out of a mathematician, I remain genuinely interested in mathematics and still appreciate the beauty of it. I enjoy the pure pleasure of thinking, deducing and reasoning.
Mathematics is probably considered as one of the least practical majors nowadays, right next to philosophy perhaps. You can’t really make a lot of money out of it quickly enough, well unless you can win a Fields Medal (The Nobel equivalent in mathematics). But without math, there will be no foundations of our modern technology. If you think about it, in computer science, the algorithms, data structures, and architecture theories, are largely mathematics to its core. Let alone its role in the AI field.
Great mathematicians are geniuses, thinkers, and even philosophers that look beyond their time, and can sometimes be perceived as borderline lunatics. In fact, Georg Cantor, the father of our modern set theory, was actually considered bipolar and spent his last days in a sanatorium. His theory, was indeed counter-intuitive, like the order of infinity, that is, there’re different levels of infinity3!
In the epic Chinese science fiction novel The Three-Body Problem (Chinese: 三体), there’re different levels of cosmos civilizations. The more advanced civilizations (not us earth people for sure) had achieved weaponizing the laws of mathematics and physics, such as, they can bend the speed of light, or even the laws of causality, or say, reduce other worlds’ dimensions cuz why not, to annihilate their enemies or burgeoning civilizations that might be later threats. Isn’t that beyond our wildest imaginations?!
As an engineer, I’m oftentimes amazed yet also baffled by the fact that in our real world, we have constants, such as π and speed of light (think this Einstein guy said we can’t travel faster than it, isn’t that disturbing eh?), etc. That can be a discussion easily leading to religions, or a higher power / designer of the world we’re living in. Cuz programmers would know that, when we’re feeling lazy, we may just hardcode stuff (or better yet, mark it as a TODO
too, so it’ll stay there until end of time. :D), or how often we just declare a constant:
// Metre per second
public const int LightSpeed = 299792458;
So what if we’re really living in a simulated environment or a giant ant farm that’s administered by a higher intelligence, like the microverse
as described in one of the episodes in Rick and Morty? Or if we’re just brains in a vat really?
-
Emphasis on the enough and true randomness. If a monkey hits keys randomly on a typewriter keyboard for an infinite amount of time, it could type any given text, such as the complete works of Shakespeare. But pure randomness is really hard to come by. Oftentimes, random numbers generated by computer programs are actually pseudo-random at best, and might be deterministic even. There is a website claims to offer true random numbers to anyone on the Internet, by randomness comes from atmospheric noise. ↩
-
The theorem stipulates that in a right triangle, the sum of the areas of the two squares on the legs (a and b) equals the area of the square on the hypotenuse (c). In China it is called the “Gougu theorem” (勾股定理). ↩
-
Let me ask this: do we have more even numbers or natural numbers? Since we know even numbers is a subset of natural numbers who can be divided by 2, so naturally, you might say of course, we have more natural numbers! But Cantor argued they actually have the same amount! The argument being, for every natural number,
1, 2, 3, 4, 5...
, if you time it by 2, then you’d have an even number. So there’s in fact a 1:1 mapping between even numbers and natural numbers! Therefore they should have the same count! IKR? Cantor also thus introduced different magnitudes of infinity for that matter - things are different in the infinity realm.. Can’t really elaborate it here. To quote Fermat’s famous words here: I had a proof that was too large to fit in the margin! ↩