Tag Archives: latex test

robert Two Principles of Mathematics by

I was explaining something in probability theory to somebody last night, and I offhandedly said the following remark:

You know, it’s interesting what sorts of mathematics come up. For example, a usual exercise in undergraduate probability is the following: Flip a coin repeatedly until a heads comes up. What’s the expected number of coin flips required?

The person asked me what the number was, and I realized that I actually didn’t know. I gave an offhand guess of three, since we’re asking about a very particular sequence of coin flips (which has exponentially small density in the measure of all sequences of coin flips, and so it should be small). I sat down to work on it before bed, and rather quickly derived the following expression.

Let X be the random variable in \{1,2, \ldots\} = \mathbb{N} with the interpretation that X = i if the ith coin flip in a sequence of flips is a head after i-1 tails. It’s straightforward to calculate \Pr[X = i] — assuming we’re flipping a fair coin, the probability of getting i-1 tails followed by a single head is (1/2)^{i}. This means our expected value will be E[X] = \sum_{i=1}^{\infty} i \Pr[X = i] = \sum_{i=1}^{\infty} i 2^{-i}.

And, wait a minute, but this sum is not trivial to evaluate! At first I did what any self-respecting mathematician/computer scientist would do (i.e. HIT IT WITH YOUR HARDEST SLEDGEHAMMERULTRATOOL AND DYNAMITE THE PROBLEM TO ACCESS IT’S SWEET GOOEY INSIDES) and applied generating functions.


This (alas) didn’t work and I fell asleep dejected.

And I woke up with the cutest solution!

To begin, here’s a secret that your math teacher just won’t ever bloody tell you:

(1) Every inequality/sum/identity in the history of mathematics just comes from writing the same thing in two different ways.

Of course, with our friend hindsight bias this is obvious — once we have the identity x = y in front of us, it’s easy to say “oh, well of COURSE x = y, it’s so obvious, duh!”.

Now, here is a second secret that your math teacher won’t ever bloody tell you:

(2) Every result ever obtained in mathematics can be broken down to a sequence of tiny, local, or otherwise easy steps.

When you say something as simple as I did in these two principles the questions of mathematics suddenly become significantly less daunting. To illustrate both of these principles, I’ll use them to evaluate our sum \sum_{i=1}^{\infty} i2^{-i} from the probabilistic puzzle above. First, let’s recall what an infinite sum actually is, as it’s kind of easy to forget: the sum

\displaystyle \sum_{i=1}^\infty i2^{-i}

is really defined as a limit of partial sums

\displaystyle \lim_{n \rightarrow \infty} \sum_{i=1}^n i2^{-i}.

So, applying our first principle from above, we’re going to rewrite \sum_{i=1}^n i2^{-i} as another function f(n) so that we can actually evaluate the limit above.

Now, how do we do this? First, just to simplify notation for ourselves, let f(n) = \sum_{i=1}^n i2^{-i}. Let’s apply our second principle from above — what are some really stupendously obvious facts about the sum f(n) = \sum_{i=1}^n i2^{-i}? Well, since it’s a frigging sum, we know that

\displaystyle f(n+1) = \sum_{i=1}^{n+1} i2^{-(i+1)} = f(n) + (n+1)2^{-(n+1)}.

Alright, here is a start. If we can apply our first principle to the sum f(n+1) and write it down in another way then maybe we’ll end up somewhere interesting. Well, what about this sum? Let’s write it down explicitly, so that we can actually see some of the structure of the terms. I’m also going to make the substitution r = 1/2 and instead write

\displaystyle f(n) = \sum_{i=1}^{n} ir^i.

Time for a side rant. Now, a math teacher, jerks as they are, will tell you to do this kind of substitution because your result is more general (or, even worse, tell you nothing at all, leaving you swimming in a soup of variables/indeterminates with no flotation device).

Everyone in any math class, ever. THE OCEAN IS VARIABLES

As usual, this is the correct information but stated in a way so that humans can’t understand it. Another way to say this “generality” assumption is, simply, people hate magic numbers! Notice that NOTHING! about the sums we’ve considered so far have needed the 2 to be there (other than the fact that our problem happens to be about coins). Well, if there’s no reason for it to be there, then why should it be there? The sum \sum_{i=1}^n ir^i is even a bit easier to swallow visually. Anyways, side rant over.

Back on track, here are the sums f(n) and f(n+1), both written down explicitly:

\displaystyle f(n) = r + 2r^2 + 3r^3 + \cdots + nr^n

\displaystyle f(n+1) = r + 2r^2 + 3r^3 + \cdots + nr^n + (n+1)r^{n+1}.

Well, recall that I said that we were trying to rewrite f(n+1) in a way other than

\displaystyle f(n+1) = f(n) + (n+1)r^{n+1}.

Applying our first principle — and this is really the leap of intuition — let’s just transform f(n) into f(n+1) in another way! How? Well, multiply f(n) by r and compare it to f(n+1):

\displaystyle rf(n) = r^2 + 2r^3 + \cdots + (n-1)r^n + nr^{n+1}.

\displaystyle f(n+1) = r + 2r^2 + 3r^3 + \cdots + nr^n + (n+1)r^{n+1}.

We’ve almost got f(n+1)! The only thing that’s missing is a single copy of each term in the sum! Phrased mathematically, we now have the identity

\displaystyle f(n+1) = rf(n) + (r + r^2 + r^3 + \ldots + r^n + r^{n+1}).

Now, the sum \sum_{i=1}^n r^i is a geometric sum which has a simple formula (fact: this simple formula can be derived in a way similar to our current investigation):

\displaystyle \sum_{i=1}^n r^i = \frac{1 - r^{n+1}}{1 - r} - 1.

So, substituting in this new simple formula gives

\displaystyle f(n+1) = rf(n) + \frac{1 - r^{n+2}}{1 - r} - 1

and then, finally finishing our application of the first principle, we can apply our early “stupid” identity for f(n+1) and get

\displaystyle f(n) + (n+1)r^{n+1} = rf(n) + \frac{1 - r^{n+2}}{1 - r} - 1.

The rest is algebra/boilerplate. Collecting the f(n) terms on the left hand side, we get

\displaystyle (1- r)f(n) = \frac{1 - r^{n+2}}{1 - r} - 1 - (n+1)r^{n+1},

then dividing both sides by (1-r) finally gives

\displaystyle f(n) = (1-r)^{-1}\left(\frac{1 - r^{n+2}}{1 - r} - 1 - (n+1)r^{n+1}\right).

Taking the limit as n \rightarrow \infty and using our knowledge that r = 1/2 < 1, we see that the terms involving r^{n+1} will disappear. This leaves

\displaystyle \lim_{n \rightarrow \infty} f(n) = \frac{1}{1-r}\left(\frac{1}{1 - r} - 1\right).

Substiting in r = 1/2, we get

\displaystyle \lim_{n \rightarrow \infty} f(n) = 2(2 - 1) = 2.

And we’re done. In expectation, you will see a heads after 2 coin flips.

You see, math is not mystical. Unless you’re a Newton or an Euler (viz. an absolutely genius), math proceeds pretty much the same for everybody. There are underlying principles and heuristics that help you do math that every established mathematician actually uses — the secret is that no one ever tells you them. Of course, I have a sneaking suspicion that this due to the fact that our high school math teachers don’t actually understand the principles themselves (while this may seem like a bit of an attack, I did graduate with people who were going to be math teachers. Most of those people should not have been math teachers).