Approximating large powers

December 3, 2022. A short guide to estimating large powers.

Introduction


Say I want to estimate a perfect power like $67^{13}$, but don’t have a calculator. If this isn’t sufficient motivation, it’s easy to make the power so large that no calculator will give you an answer! How do I go about approximating it? I’ll build up a few techniques that are sufficient for an order of magnitude estimate, and even a significant digit or two.

The proximate power problem.
Give an order of magnitude estimate of $n^p$, where $n$ and $p$ are potentially large integers, without a calculator. For bonus points, provide a significant digit.

Perfect powers


Tip 1. Single-digit powers.
Know how to relate single-digit powers to powers of $10$.

The first step is to relate single-digit powers to powers of $10$. For instance, as commonly known to coders, $2^{10} = 1024 \approx 10^3$, so we can approximate binary powers easily enough. Here’s a list of tricks for $2$ to $7$, omitting powers of $2$ and $3$:

\[\begin{align*} 2^{10} & = 1024 \approx 10^3 \\ 3^2 & = 9 \approx 10 \\ 5 & = \frac{10}{2} \\ 6^9 & = 1.01 \times 10^7 \approx 10^7 \\ 7^2 & = 49 \approx \frac{100}{2}. \end{align*}\]

Also, for good measure:

\[e^3 \approx 20.\]

We can use these to give quick and dirty estimates. For instance,

\[\begin{align*} 67^{13} & = 6.7^{13} \times 10^{13} \\ & \approx 7\times 7^{12}\times 10^{13} \\ & \approx 7 \times 49^6 \times 10^{13} \\ & \approx \frac{7}{2^6} \times 100^6 \times 10^{13} \\ & \approx 10^{24}. \end{align*}\]

If you get a calculator out, you find the answer is in fact

\[67^{13} = 5.5 \times 10^{23},\]

so this is correct to the nearest order of magnitude. Great! But clearly, by replacing $6.7$ by $7$ on the second line we are going to overestimate. Can we do better? The rest of this post is devoted to exploring techniques for doing this, but if you’re happy with order of magnitude, stop here.

Binomial boost


Tip 2. Binomial expansions.
Improve accuracy by performing a binomial expansion.

The binomial theorem gives us a way to improve these estimates. In general, we have

\[(1+x)^n = 1 + nx + \binom{n}{2}x^2 + \cdots + x^n = \sum_{k=0}^n \binom{n}{k}x^k.\]

So, for instance,

\[\begin{align*} 67^{13} &= 70^{13}\left(1 - \frac{0.3}{7}\right)^{13} \\ & = 70^{13}\left[1 - \frac{13\times 0.3}{7} + \frac{13\times 12 \times (0.3)^2}{2\times 7^2} - \frac{13 \times 12 \times 11 \times (0.3)^3}{6\times 7^3} + \cdots\right]\\ & \approx 70^{13}\left[1 - 0.55 + 0.14 - 0.02 \right]\\ & \approx 0.57 \times 10^{24} \\ & = 5.7 \times 10^{23}, \end{align*}\]

using the estimate from the previous section. This is much better! We’ve ignored the factor of $70/2^6$, which means we’ve underestimated, but we’ve also replaced $7^{12}$ with $(100/2)^6$, which is an overestimate, and the two almost cancel. As an exercise, you can use the binomial approximation to check this.

In doing a binomial expansion, where should you stop? Depends on how much precision you want. Here, I went to third order since it gave terms of size $\sim 0.01$, which is the precision I wanted to try and match the correct answer above. How did I know? Well, I know terms in the expansion have the form

\[\binom{n}{k}x^k = \binom{n}{k-1} x^{k-1} \times \frac{x (n-k+1)}{k},\]

so for $n = 13$ and $x = -0.3/7$, progressive terms shrink by $\sim 0.04$ give or take. So I can probably stop after a term of the size I want, in this case, the third term, which was order $\sim 0.01$.

Fast factors


Tip 3. Factorize.
Factorize to simpler nearby numbers, then restore the original with a binomial expansion.

There are other ways to skin this cat. Another strategy is factoring to a simpler number nearby. In our case, we can note that

\[67 \approx 66 = 6 \times 11.\]

Then

\[\begin{align*} 67^{13} & \approx 6^{13} \times 11^{13} \\ & \approx 6^4 \times 6^9 \times 10^{13}\times (1 + 0.1)^{13} \\ & \approx 1300 \times 10^{20} \times (1 + 1.3 + 0.78 + 0.286) \\ & \approx 1.3 \times 10^{23} \times 3.37 \\ & \approx 4.4 \times 10^{23}, \end{align*}\]

using our trick $6^9 \approx 10^7$ on the third line. Again, we can improve this estimate by binomially expanding from $66^{13}$ to $67^{13}$, a task I leave for the diligent reader. Taking just the leading term in this second binomial expansion gives $5.3 \times 10^{23}$, a decent improvement. I’m not sure I like this method better — it involves two expansions — but it does illustrate the utility of factoring.

Lucky logs


Tip 4. Take logarithms.
Use log laws and the Taylor expansion to estimate the log of the base.

The last method we’ll look at is logarithms. Here, we use the fact that

\[n^p = 10^{p\log_{10}n},\]

so if we know $\log_{10}n$ we immediately have an order of magnitude estimate. We can use log laws

\[\log_b (xy) = \log_bx + \log_b y, \quad \log_b x = \frac{\ln x}{\ln b}\]

where $\ln$ is the natural logarithm, and the Taylor expansion

\[\ln(1 - x) = -x - \frac{x^2}{2} - \frac{x^3}{3} - \cdots.\]

Let’s use these to estimate $\log_{10} 67$. We’ll also exploit the fact that $\ln 10 \approx 2.3$. From log laws, we have

\[\begin{align*} \log_{10} 67 & = 2 + \log_{10} 0.67 \\ & = 2 + \frac{\ln 0.67}{\ln 10} \\ & \approx 2 + \frac{\ln 0.67}{2.3}. \end{align*}\]

We now focus on the Taylor expansion. Since $0.67 \approx 1 - 1/3$, we can write

\[\ln 0.67 \approx \ln\left(1 - \tfrac{1}{3}\right) = -\frac{1}{3} - \frac{1}{18} - \frac{1}{3\times 27} - \cdots \approx -\frac{37}{81}.\]

So we get an index

\[\begin{align*} 13\log_{10} 67 & \approx 26 - \frac{13\times 37}{2.3\times 81} \\ & \approx 26 - \frac{13 \times 35}{2.5 \times 80} \\ & \approx 26 - 2.275 \\ & = 23.725. \end{align*}\]

So we recover our order of magnitude estimate

\[67^{13} \approx 10^{23.725}.\]

Evaluating the mantissa with a calculator, we get

\[10^{0.725} \approx 5.3,\]

so this method is comparable in accuracy to our binomial expansions. In both cases, we kept terms up to $x^3$, so this is about what we expect.

Magic mantissas


Tip 5. Evaluate the mantissa.
Get a significant digit in the log method by splitting the mantissa into a simple part and a small part you can Taylor expand with the exponential.

The disadvantage of the log method is that it’s a bit hard to see what the mantissa is. Hard, but not impossible! One method is to use the Taylor series for the exponential:

\[e^x = 1 + x + \frac{1}{2}x^2 + \frac{1}{3!}x^3 + \cdots .\]

This turns out to be a bit messy to use directly, because the index is large and you need to include a bunch of terms in the expansion to get stable digits. Instead, we we split $0.725 = 0.7 + 0.025$, and deal with $0.7$ first:

\[\begin{align*} 10^{0.7} & \approx 10^{7/10} \\ & = (10^3)^{(7/10) \times (1/3)} \\ & \approx \sqrt[3]{(2^{10})^{7/10}}\\ & = \sqrt[3]{2^7} \\ & = \sqrt[3]{128} \\ & \approx 5, \end{align*}\]

since $5^3 = 125$. The cute thing is that we have just used facts from our “power table”. We can use the exponential expansion for the remaining $0.025 = 1/40$, with

\[10^{1/40} = e^{\ln 10/40} \approx e^{2.3/40} \approx 1 + \frac{2.3}{40} \approx 1.06,\]

using only the leading term in the expansion. We then multiply to find

\[10^{0.725} = 10^{0.7} \times 10^{0.025} \approx 5 \times 1.06 = 5.3,\]

as claimed above!

Written on December 3, 2022
Math   Hacks