aboutsummaryrefslogtreecommitdiff
path: root/hidden/2019-05-19-large-numbers.md
blob: cb619e99df358e3e6d444defb8814b3eb5c9570f (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
---
title: A Blueprint for Large Numbers
route: /large-numbers
date: 2019-05-19
description: Let's generate numbers that can't fit in the observable universe.
---

Consider a modest function "A," which takes a number and adds one to it.

$$
\begin{aligned}
  A(1) &= 2 \\
  A(2) &= 3  \\
  A(99) &= 100
\end{aligned}
$$

It's not much of an operator, and is easily defeated by its counterpart: "evil A."

$$
\begin{aligned}
  \check A(2) &= 1 \\
  \check A(3) &= 2 \\
  \check A(100) &= 99
\end{aligned}
$$

We can apply "A" multiple times.

$$
\begin{aligned}
  A(A(1)) = A(2) &= 3 \\
  A(A(A(A(1)))) &= 5
\end{aligned}
$$

Repeating "A" is a little tiring, so we can use a superscript to make things a little more concise.

$$
\begin{alignedat}{2}
  A(A(1)) &= A^2(1) &&= 3 \\
  A(A(A(A(10)))) &= A^4(10) &&= 14
\end{alignedat}
$$

Since the superscript implies "add 1 this many times," the following properties unfold:

$$
\begin{aligned}
A^n(1) &= 1 + n \\
A^n(10) &= 10 + n \\
A^n(99) &= 99 + n
\end{aligned}
$$

Or, more generally:

$$ A^n(m) = m + n $$

Behold, **addition**!

## Small steps

Our goal is to make large numbers, so we may start throwing some of them at A in hopes of making them even bigger.

$$
\begin{aligned}
A^{1000}(1000) &= 2000 \\
A^{1000000}(1000000) &= 2000000
\end{aligned}
$$

But we're not making much progress. For starters, we have to pass in _two_ big numbers - what a waste. Let's not repeat ourselves so much by creating a new function "B":

$$ B(n) = A^n(n) $$

Now we can pass large numbers into B just once - half the work (I checked!).

$$
\begin{aligned}
B(1000) &= A^{1000}(1000) \\
&= 1000 + 1000 \\
&= 2000 \\
B(1000000) &= 2000000 \\
B(1000000000) &= 2000000000
\end{aligned}
$$

We can see that the following property holds:

$$ B(n) = A^n(n) = n + n = 2 \cdot n $$

Behold, **multiplication!**

Try as it might, "evil A" can't stop our new friend "B" from taking our numbers to great heights.

$$
\begin{aligned}
\check A(n) &= n - 1 \\
B(n) &= 2 \cdot n \\
\check A(B(10)) &= 20 - 1 = 19 \\
\check A(B(100)) &= 199 \\
\check A(B(5000)) &= 9999 \\
\end{aligned}
$$

But "evil B" can, stopping our numbers dead in their tracks.

$$
\begin{aligned}
\check B(n) &= \frac{n}{2} \\
B(n) &= 2 \cdot n \\
\check B(B(10)) &= \frac{20}{2} = 10 \\
\check B(B(100)) &= 100 \\
\check B(B(5000)) &= 5000 \\
\end{aligned}
$$

We'll need something stronger.

## Slightly bigger steps

We have a function "B" which _doubles_ a number.

$$
\begin{aligned}
B(1) &= 2 \\
B(99) &= 198 \\
B(500) &= 1000
\end{aligned}
$$

We can apply "B" multiple times.

$$
\begin{aligned}
B(B(1)) = B(2) &= 4 \\
B(B(B(10))) &= 80
\end{aligned}
$$

To shorten things, we can use our trusty friend, the superscript.

$$
\begin{alignedat}{2}
B(B(1)) &= B^2(1) &&= 4 \\
B(B(B(10))) &= B^3(10) &&= 80
\end{alignedat}
$$

This pattern may be a bit harder to spot, but we can handle it by expanding things a little.

$$
\begin{aligned}
B^4(5) &= 2 \cdot B^3(5) \\
&= 2 \cdot 2 \cdot B^2(5) \\
&= 2 \cdot 2 \cdot 2 \cdot B(5) \\
&= 2 \cdot 2 \cdot 2 \cdot 2 \cdot 5 \\
&= 2^4 \cdot 5
\end{aligned}
$$

The following pattern emerges:

$$ B^n(5) = 2^n \cdot 5 $$

Or, more generally:

$$ B^n(m) = 2^n \cdot m $$

Behold, **exponentiation!**

Just as before, we'll consolidate m and n by introducing a new function "C."

$$ C(n) = B^n(n) = 2^n \cdot n $$

## Getting there

Our numbers are starting to grow pretty quickly:

$$
\begin{alignedat}{2}
C(3) &= 2^3 \cdot 3 &&= 24 \\
C(10) &= 2^{10} \cdot 10 &&= 10240 \\
C(100) &= 2^{100} \cdot 100 &&= 12676506\mathellipsis
\end{alignedat}
$$

Passing 100 to our friend "C" produces `126765060022822940149670320537600`, which is a whopping 33 digits in length. Switch the 100 to 1000 and we get:

<pre><code>107150860718626732094842504906000
181056140481170553360744375038837
035105112493612249319837881569585
812759467291755314682518714528569
231404359845775746985748039345677
748242309854210746050623711418779
541821530464749835819412673987675
591655439460770629145711964776865
421676604298316526243868372056680
69376000
</code></pre>

Coming in at 305 digits. Pretty huge - larger than [the number of particles in the universe](https://en.wikipedia.org/wiki/Elementary_particle#Common_elementary_particles) - but still easily represented here in this article.

Additionally, our "evil B" from earlier is no match for us now.

$$
\begin{aligned}
\check B(n) &= \frac{n}{2} \\
C(n) &= 2^n \cdot n \\
\check B(C(10)) &= 5120 \\
\check B(C(100)) &= 633825\mathellipsis \text{(32 digits)} \\
\check B(C(1000)) &= 535754\mathellipsis \text{(304 digits)}\\
\end{aligned}
$$

Try as it might, "evil B" can only occasionally knock a single digit off our numbers.

A new challenger approaches, however, that can take them out using its secret weapon - [the logarithm](https://www.khanacademy.org/math/algebra2/exponential-and-logarithmic-functions/introduction-to-logarithms/a/intro-to-logarithms).

$$
\begin{aligned}
\check C(n) &= \lg(n) \\
C(n) &= 2^n \cdot n \\
\check C(C(10)) &= 13.321\mathellipsis \\
\check C(C(100)) &= 106.643\mathellipsis \\
\check C(C(1000)) &= 1009.965\mathellipsis  \\
\end{aligned}
$$

Our numbers are _barely_ able to escape the mighty logarithm. We'll need something stronger.

## To new heights

We have a function "C" which raises 2 to the power "n" and multiplies it by "n"

$$
\begin{alignedat}{2}
C(n) &= 2^n \cdot n \\
C(3) &= 2^3 \cdot 3 &&= 24 \\
C(10) &= 2^{10} \cdot 10 &&= 10240 \\
\end{alignedat}
$$

This function has a little sibling which does the same thing, but does not multiply by "n". It won't produce numbers quite as big, but will be a little easier for us to work with.

$$
\begin{aligned}
\dot C(n) &= 2^n \\
\dot C(3) &= 8 \\
\dot C(10) &= 1024
\end{aligned}
$$

We can apply "little C" multiple times.

$$
\begin{alignedat}{2}
\dot C(n) &= 2^n \\
\dot C(\dot C(n)) &= 2^{\dot C(n)} &&= 2^{2^n} \\
\dot C(\dot C(\dot C(n))) &= 2^{\dot C(\dot C(n))} \\
&= 2^{2^{\dot C(n)}} &&= 2^{2^{2^{n}}}
\end{alignedat}
$$

Just as before, we can use our trusty friend the superscript.

$$\dot C^5(n) = 2^{2^{2^{2^{2^n}}}}$$

Repeated applications of "little C" result in these fairly alien "towers" of 2s. In particular:

$$\dot C^m(n) = \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2^n}}}}}}}_{\text{m copies of 2}}$$

Once again we can consolidate m and n:

$$D(n) = \dot C^n(n) = \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2^n}}}}}}}_{\text{n copies of 2}}$$

Just as we removed the trailing end for "C", we'll remove the trailing n for "D" to simplify things.

$$
\begin{aligned}
C(n) &= 2^n \cdot n \\
\dot C(n) &= 2^n \\
D(n) &= \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2^n}}}}}}}_{\text{n copies of 2}} \\
\dot D(n) &= \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{\text{n copies of 2}}
\end{aligned}
$$

These "towers of exponents" are referred to as "[tetrations](https://en.wikipedia.org/wiki/Tetration)" and are typically represented using [Knuth's up-arrow notation](https://en.wikipedia.org/wiki/Knuth%27s_up-arrow_notation).

$$
\dot D(5) = 2^{2^{2^{2^2}}} = 2 \uparrow \uparrow 5
$$

They're bizarre-looking, and grow...**really quickly**. How quickly?

$$
\begin{alignedat}{2}
\dot D(2) &= 2^2 &&= 4 \\
\dot D(3) &= 2^{2^2} &&= 16 \\
\dot D(4) &= 2^{2^{2^2}} &&= 65536 \\
\dot D(5) &= 2^{2^{2^{2^2}}} &&= 2^{65536}
\end{alignedat}
$$

At just 5 items in, we're produced a number that is 19,729 digits in length. Much larger than anything we've seen so far, but still _tangible_. In fact, I can print this number at size 11 font with 1" margins in just 7 sheets of paper (about 3,000 digits per page).

![a print preview showing the very long number (20035299...) with "Total: 7 pages"](/img/digits.png)

Why stop there?

$$\dot D(6) = 2^{2^{2^{2^{2^2}}}} = \text{???}$$

What _is_ this number? Concretely, it's 2 raised to the giant number we just saw. How much larger does that make it?

While we could print `D(5)` on 7 pages of paper, we'll need 7 pages of paper **just to print the number of digits in `D(6)`**. What if we wanted to print `D(6)` itself? We'll need about `D(5)` pages.

More specifically, we'll need `D(5) / 3,000` pages, but `D(5)` is so massive the `/ 3,000` does absolutely nothing to it.

How about `D(7)`? We'll need `D(5) / 3,000` pages to print its digits, and `D(6) / 3,000` pages to print the number itself. There's a pattern here, but not one that translates well into physical sheets of paper. Simply put, the number's big.

In fact, our function generates numbers so big that "evil C" is quickly drowned by them.

$$
\begin{alignedat}{2}
\check C(n) &= \lg(n) \\
\check C(\dot D(2)) &= \lg{(2^2)} &&= 2 \\
\check C(\dot D(3)) &= \lg{(2^{2^2})} &&= 2^2 \\
\check C(\dot D(4)) &= \lg{(2^{2^{2^2}})} &&= 2^{2^2} \\
\check C(\dot D(5)) &= \lg{(2^{2^{2^{2^2}}})} &&= 2^{2^{2^2}} \\
\check C(\dot D(6)) &= \lg{(2^{2^{2^{2^{2^2}}}})} &&= 2^{2^{2^{2^2}}}
\end{alignedat}
$$

Try as it might, "evil C" can only knock off a single item from our ever-growing tower of exponents.

A tower of exponents is a real force to be reckoned with.

## But not big enough

We have a function "D" which generates a tower of 2s with a height of "n."

$$
\dot D(n) = \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{\text{n copies of 2}}
$$

We can apply this function to itself.

$$
\begin{aligned}
\dot D(\dot D(n)) &= \dot D(\underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{\text{n copies of 2}}) \\
&= \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{(\underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{\text{n copies of 2}})\text{ copies of 2}}
\end{aligned}
$$

In the previous section, we saw how `D(n-1)` dictated the **number of digits** for `D(n)`. Well, `D(D(n))` grows not on the level of _exponents_, but on the level of the _number of exponents in the tower_.

**While `D(6)` was practically impossible to imagine, `D(D(6))` is pure nightmare fuel. Let's continue.**

Just as earlier, we can use a superscript to simplify things:

$$
\left.
\dot D^m(n) = \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{(\underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{(\cdot^{\cdot^{\cdot}}) \text{ copies of 2}})\text{ copies of 2}}
\right\} \text{m times}
$$

And we can consolidate m and n like so:

$$
\begin{aligned}
E(n) &= \dot D^n(n) \\
&= \left.
        \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{(\underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{(\cdot^{\cdot^{\cdot}}) \text{ copies of 2}})\text{ copies of 2}}
    \right\} \text{n times}
\end{aligned}
$$

These towers-of-towers can be hard to read (and harder to write), so we can simplify things a bit using [our previous up-arrow notation](https://en.wikipedia.org/wiki/Knuth%27s_up-arrow_notation).

$$
\begin{aligned}
\dot D(n) &= 2 \uparrow \uparrow n \\
\dot D(\dot D(n)) &= 2 \uparrow \uparrow (2 \uparrow \uparrow n) \\
\dot D(\dot D(\dot D(n))) &= 2 \uparrow \uparrow (2 \uparrow \uparrow (2 \uparrow \uparrow n)) \\
\dot D^m(n) &= \underbrace{\dot D(\dot D( \cdots \dot D(n)))}_{\text{m copies of } \dot D} \\
&= \underbrace{2 \uparrow \uparrow (\cdots (2 \uparrow \uparrow n))}_{\text{m copies of 2}}
\end{aligned}
$$

(and consolidate m and n):

$$
\begin{aligned}
E(n) &= \dot D^n(n) \\
&= \underbrace{2 \uparrow \uparrow (2 \uparrow \uparrow (\cdots (2 \uparrow \uparrow n))}_{\text{n copies of 2}}
\end{aligned}
$$

Lastly, we'll want to get rid of that pesky "n" at the end and create a "little E" just as we did for "C" and "D".

$$
\begin{aligned}
D(n) &= \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2^n}}}}}}}_{\text{n copies of 2}} \\
\dot D(n) &= \underbrace{2^{2^{2^{\cdot^{\cdot^{\cdot^{2}}}}}}}_{\text{n copies of 2}} \\
E(n) &= \underbrace{2 \uparrow \uparrow (2 \uparrow \uparrow (\cdots (2 \uparrow \uparrow n))}_{\text{n copies of 2}} \\
\dot E(n) &= \underbrace{2 \uparrow \uparrow (2 \uparrow \uparrow (\cdots (2 \uparrow \uparrow 2))}_{\text{n copies of 2}}
\end{aligned}
$$

Conveniently, mathematicians have an elegant way to represent "apply double-up-arrow n times," and all it takes is adding a third arrow.

$$
\begin{aligned}
\dot E(n) &= \underbrace{2 \uparrow \uparrow (2 \uparrow \uparrow (\cdots (2 \uparrow \uparrow 2))}_{\text{n copies of 2}} \\
\dot E(n) &= 2 \uparrow \uparrow \uparrow n
\end{aligned}
$$

## Arrows, arrows, arrows

In fact, if we repeat the process we used to generate "B" through "E":

$$
\begin{aligned}
E^m(n) &= \underbrace{E(E(\cdots(E(n))}_{\text{m times}} \\
E^n(n) &= \underbrace{E(E(\cdots(E(n))}_{\text{n times}} \\
F(n) &= E^n(n) \\
G(n) &= F^n(n) \\
H(n) &= G^n(n) \\
\dots
\end{aligned}
$$

All we're really doing is **adding more arrows**.

$$
\begin{aligned}
E(n) &= 2 \uparrow \uparrow \uparrow n \\
F(n) &= 2 \uparrow \uparrow \uparrow \uparrow n \\
G(n) &= 2 \uparrow \uparrow \uparrow \uparrow \uparrow n \\
H(n) &= 2 \uparrow \uparrow \uparrow \uparrow \uparrow \uparrow n \\
\dots
\end{aligned}
$$

Eventually the arrows themselves will become unweildy:

$$
Z(n) = \underbrace{2 \uparrow \uparrow \cdots \uparrow n}_\text{25 arrows}
$$

Worry not, for we can provide a superscript _to the arrow_ itself. (Keep in mind that our numbers became _incomprehensibly_ large 23 arrows ago.)

$$
\begin{aligned}
Z(n) &= \underbrace{2 \uparrow \uparrow \cdots \uparrow n}_\text{25 arrows} \\
Z(n) &= 2 \uparrow^{25} n
\end{aligned}
$$

So, what if we wanted to continue growing the number of arrows?

<div style="padding: 8px; background: #e0e0e0; color: red">[Existential Error] Shutting down...
</div>

I'll leave that to you, dear reader, for I am exhausted.

Thanks for reading :) If you enjoyed this article, you'll probably love [Graham's Number](https://www.youtube.com/watch?v=GuigptwlVHo) and [TREE(3)](https://www.youtube.com/watch?v=3P6DWAwwViU).