# How much can we trust mathematical software when working with large numbers, and how much memory it needs to work with these numbers?

For example, I want to evaluate the expression:

$$3^{3^{{3}^{3}}}$$

so I used wolframalpha.com (it's free, and I don't own any software), which returned the scientific notation of the number above, namely:

$$1.258014290627491317860390698... × 10^{3638334640024}$$

Which is huge. However, for the number below

$$4^{4^{{4}^{4}}}$$

Wolfram can't return a scientific notation, probably because it's a much larger number and it needs a lot of memory.

Questions: a) How much can we trust that

$$3^{3^{{3}^{3}}} \approx 1.258014290627491317860390698... × 10^{3638334640024}$$

b) how much memory (aproximate) it needs to evaluate

$$3^{3^{{3}^{3}}}$$

and

$$4^{4^{{4}^{4}}}$$

I'm guessing a lot of terabytes and something that a home computer can't handle. But for the first number, Wolfram can, and the second number, it can't. How do we even find how much size we need to calculate these numbers?

Question a):

Here is the output from python console.

>>> import math
>>> math.log(3,10) * (3**(3**3))
3638334640024.0996
>>> math.pow(10, 0.0996)
1.2577664324512539


The first 5 most significant digits are almost the same of that of Wolfram, 12577 vs 12580.

If we try the following at my favorite online arbitrary precision calculator,

pow(3.0000000000000000000000000000000, pow(3, pow(3, 3)))


we get

1.2580142906274913178603906982032e3638334640024


which is completely consistent with Wolfram. So Wolfram can be fully trusted on this particular result.

You might be wondering why "$$3.0000000000000000000000000000000$$" is entered instead of a simple "$$3$$". Had "$$3$$" been used, that calculator would have performed integer calculations without loss of precision, which will run out of 30-second time limit in our case. "$$3.0$$" would be enough to instruct that calculator to use floating numbers, which, however, would have only 2 digits of precision. That long string of 0s is used to specify 32 digits of precision of floating-point numbers.

Question b):

The computation above showed there are 3638334640025 digits if we express $$3^{3^{3^3}}$$ as a decimal integer. It we store 2 digits in one 8-bit byte, we need 1.82 terabyte storage.

However, if we ask that online calculator to compute $$4^{4^{4^4}}$$,

pow(4.0000000000000000000000000000000, pow(4, pow(4, 4)))


it say,

Complete loss of accurate digits


That is not a surprise since the exponent $$4^{4^4}$$ $$=$$ $$13407807929942597099574024998205846127479365820592393377723561443721764030073546976801874298166903427690031858186486050853753882811946569946433649006084096$$ $$\approx$$ $$1.34×10^{154}.$$ We can work around this out-of-limit error by computing directly the exponent of 10 in $$4^{4^{4^4}}$$ by using $$\log$$ with base 10.

log(4.0000000000000000000000000000000,10) * pow(4, pow(4, 4))


8.0723047260282253793826303970853e153

That number of digits, about $$8\times10^{153}$$ is much more than vigintillion in long scale. To store $$4^{4^{4^4}}$$ as a decimal integer, it is not enough even if all atoms in the known universe are used, assuming each of them can store more digits than all available computer storage on earth.
Compute 4^4^4 and you will know how much pairs of bits 4^4^4^4 will require to represent.