The Back of the EnvelopeBlather of dubious value.
https://pillsy.github.io/
Tue, 29 Dec 2015 18:04:02 +0000Tue, 29 Dec 2015 18:04:02 +0000Jekyll v2.4.0There are lots of primes<p>Really, “lots” doesn’t even cover it, because there are an infinite number
of prime numbers. Like most interesting facts in mathematics, there are
many ways of proving this. The most familiar, and probably oldest, appears
in <a href="http://primes.utm.edu/notes/proofs/infinite/euclids.html">Euclid’s <em>Elements</em></a>.</p>
<p>It’s a very simple proof by contradiction. Start by assuming that there are
only $ N $ primes, $ p_1, \ldots, p_N $. If you multiply them all together
and add one, you get</p>
<script type="math/tex; mode=display">m = p_1 \cdots p_N + 1</script>
<p>None of the $ p_j $s divide $ m $, so either $ m $ itself is prime or
it has a prime factor $ q \ne p_i $ for all $ i $. Either way, there
must be a prime that wasn’t in our original set, contradicting the
assumption that there are only a finite number of primes.</p>
<p>Euclid’s proof may be a classic, but it’s not my favorite. My favorite is
more complicated. Complexity is not usually a virtue, but the roundabout
nature of this proof is, in a word, neat. It depends on two very important
facts, neither of which I’ll prove because I’m lazy.</p>
<p>The first fact is that any positive integer $ m $<sup id="fnref:names"><a href="#fn:names" class="footnote">1</a></sup> has a unique
“prime factorization”, which means that</p>
<script type="math/tex; mode=display">m = p_1^{k_1} \cdots p_n^{k_n}</script>
<p>where the $ p_i $s are <strong>distinct</strong> primes and the $ k_i$s are positive
integers<sup id="fnref:fta"><a href="#fn:fta" class="footnote">2</a></sup>. If you allow the $ k_i $s to be zero, the factorization is
no longer unique. On the other hand, $ n $ itself can be zero, in which case
$ m = 1 $, because the product of an empty list of things is $ 1 $.<sup id="fnref:monoid"><a href="#fn:monoid" class="footnote">3</a></sup></p>
<p>The second fact is that the harmonic series diverges. The harmonic series is
the sum</p>
<script type="math/tex; mode=display">\frac{1}{1} + \frac{1}{2} + \frac{1}{3} + \cdots</script>
<p>As you sum together more and more terms in the series, the total keeps
growing without bound. If you pick some number $ x $, there’s a number
$ L $ such that if I sum together $ L $ or more terms, the result will
be greater than $ x $. It doesn’t matter what value you pick for $ x $:
eventually the total will be larger. For even a relatively small
$ x $, However, you’ll need to sum <strong>a lot</strong> of terms. If $ x = 10 $,
you’ll need to sum more than $12\,000$ of them!<sup id="fnref:terms"><a href="#fn:terms" class="footnote">4</a></sup></p>
<p>Now, rewrite the denominator for each term in the harmonic series as its
prime factorization, like so:</p>
<script type="math/tex; mode=display">\frac{1}{1} + \frac{1}{2^1} + \frac{1}{3^1} + \frac{1}{2^2} +
\frac{1}{5^1} + \frac{1}{2^1 3^1} + \cdots</script>
<p>Already, it seems like I can pull out powers of $ 1/2 $, turning the
infinite series into a product of <strong>two</strong> infinite series:</p>
<script type="math/tex; mode=display">\left(\frac{1}{2^0} + \frac{1}{2^1} + \frac{1}{2^2} + \cdots \right)
\left(\frac{1}{1} + \frac{1}{3^1} + \frac {1}{5^1} + \cdots\right)</script>
<p>If you aren’t convinced, try expanding out only the explicitly listed terms
and see that everything up to $ 1/6 $ is included, along with some
other terms.</p>
<p>Now, I’m going to assume, again, that there are only $ N $ primes<sup id="fnref:cons"><a href="#fn:cons" class="footnote">5</a></sup>,
$ p_1, \ldots, p_N $. For convenience, I’ll assume that they’re indexed
in order of their size, so $ p_1 = 2 $, $ p_2 = 3 $, and so on. By
repeatedly factoring out powers of $ 1/p_j $ for each of the primes
$ p_j $, I can write the harmonic series a product of $ N $ infinite
series.</p>
<script type="math/tex; mode=display">\left( \frac{1}{2^0} + \frac{1}{2^1} + \frac{1}{2^2} + \cdots \right)
\left( \frac{1}{3^0} + \frac{1}{3^1} + \frac{1}{3^2} + \cdots \right)
\cdots
\left( \frac{1}{p_N^0} + \frac{1}{p_N^1} + \frac{1}{p_N^2} + \cdots \right)</script>
<p>This looks much prettier with product and sum notation, using big
capital $\Pi$s and $\Sigma$s:<sup id="fnref:notation"><a href="#fn:notation" class="footnote">6</a></sup></p>
<script type="math/tex; mode=display">\prod_{j = 1}^N \left(\sum_{k = 0}^\infty \frac{1}{p_j^k}\right)</script>
<p>Then using the basic fact that $ 1/p_j^k = (1/p_j)^k $, the sums are
revealed to be geometric series. As long as $ -1 < x < 1 $,</p>
<script type="math/tex; mode=display">\sum_{k = 0}^\infty x^k = \frac{1}{1-x}</script>
<p>Now the harmonic series is just a simple, finite product!<sup id="fnref:euler"><a href="#fn:euler" class="footnote">7</a></sup></p>
<script type="math/tex; mode=display">\prod_{j = 1}^N \frac{1}{1 - 1/p_j }</script>
<p>Of course, if the harmonic series is a product of a finite number of
finite terms, then it must be finite. Since we know the harmonic series
diverges, we have another contradiction, again showing that the assumption
that there are a finite number of primes is false. QED, as we say in the
business.</p>
<div class="footnotes">
<ol>
<li id="fn:names">
<p>This $ m $ is completely independent from the $ m $ used above.
One of the hardest parts about programming is coming up with good names
for functions and variables; in math this is even harder, since
long-standing tradition means sticking to names that are a single
letter! In the face of such scarcity, mathematicians recycle
aggressively. <a href="#fnref:names" class="reversefootnote">↩</a></p>
</li>
<li id="fn:fta">
<p>This fact is <strong>so</strong> important that some people call it the
<a href="http://mathworld.wolfram.com/FundamentalTheoremofArithmetic.html">Fundamental Theorem of Arithmetic</a>! <a href="#fnref:fta" class="reversefootnote">↩</a></p>
</li>
<li id="fn:monoid">
<p>This is a general property of <a href="https://apocalisp.wordpress.com/2010/06/14/on-monoids/">monoids</a>, where using a
monoid operation to fold together an empty list of elements always gives
the identity element. <a href="#fnref:monoid" class="reversefootnote">↩</a></p>
</li>
<li id="fn:terms">
<p>I found the answer using a trick I may talk about in a future
post, but you can also find the answer by brute force. For instance,
it’s a one-liner in Haskell:</p>
<pre><code class="language-haskell">length . takeWhile (<= 10) . scanl (+) 0 . map (1 /) $ [1..]
</code></pre>
<p>If you copy and paste that into GHCi, you should get <code>12367</code> as the
result. This will run instantaneously, but be careful, because as
$ x $ gets larger, it’ll get very slow very fast. <a href="#fnref:terms" class="reversefootnote">↩</a></p>
</li>
<li id="fn:cons">
<p>One interesting consequence of having a finite number of primes
is that when you factor a number into primes, you can include <strong>all</strong>
the primes, some raised to the zeroth power, and still have a unique
way of writing the factorization! <a href="#fnref:cons" class="reversefootnote">↩</a></p>
</li>
<li id="fn:notation">
<p>This notation is very similar to a <code>for</code> loop. In the curly
brace language of your choice,</p>
<script type="math/tex; mode=display">\sum_{k = 1}^{n} f(k)</script>
<p>is equivalent to</p>
<pre><code class="language-java">double result = 0.0;
for (int k = 1; k <= n; ++k) {
result += f(k);
}
return result;
</code></pre>
<p>In addition to using the same damn one-letter variable names over
and over agin, no matter how confusing it is, mathematicians also
have an <a href="http://www.cs.utexas.edu/users/EWD/ewd08xx/EWD831.PDF">annoying habit of indexing from one</a>. <a href="#fnref:notation" class="reversefootnote">↩</a></p>
</li>
<li id="fn:euler">
<p>This is called the <a href="https://en.wikipedia.org/wiki/Riemann_zeta_function#Euler_product_formula">“Euler product”</a>, after Leonhard
Euler, who discovered it. I’m pretty sure the second proof in this
post is also due to Euler. <a href="#fnref:euler" class="reversefootnote">↩</a></p>
</li>
</ol>
</div>
Sat, 29 Dec 2012 00:00:00 +0000
https://pillsy.github.io/2012/12/29/there-are-lots-of-primes.html
https://pillsy.github.io/2012/12/29/there-are-lots-of-primes.html