The Arithmetic of Logs

Logarithms are as a good place to start as any to start a maths blog.

Before everyone calculated using one of these…

As they progress in mathematics, everyone eventually encounters logarithms. Nowadays these are introduced as a purely algebraic tool, useful for bringing variables down from powers and for solving index equations. But not so long ago logarithms were primarily an arithmetical tool, indispensable in basic calculation. Via tables or slide rules, they were used daily by millions to multiply and divide, and to take powers and roots. You don’t even have to be that old to actually remember doing this.

However, logarithms in basic arithmetic were made obsolete by the arrival of affordable electronic calculators in the late 1970’s. The world collectively put away its slide rules and log tables, and nowadays most people — myself included — will study the complete algebra of logs without ever learning about their original purpose and function. A little sad when you think about it.

So, this post is intended as an introduction to the basic arithmetic of logs for those still unaware of it; and as a refresher for older/enlightened readers. However, I’ll also show how logs live on as alternative to direct calculation. Even today, when the chips are down, the power of logs can still trump direct calculation by even the most powerful computers.

The log rules and the log tables

Most learn the algebra of logs from their definition as an inverse of exponentiation. If $b^m=x$, then $\log_b x = m$, and from this definition the basic rules of logs follow. Lists vary, but these rules usually include the following.
\begin{align}
\bullet&\ \text{I} &\log_b(xy)&= \log_b(x) + \log_b(y)\\
\bullet&\ \text{II} &\log_b(x/y)&= \log_b(x) – \log_b(y)\\
\bullet&\ \text{III}&\log_b(x^p)&= p\log_b(x)\\
\bullet&\ \text{IV} &\log_b(a)&= \frac{\log_c(a)}{\log_b(c)}
\end{align}

This is essentially as much as modern students learn (probably wondering all the while what on earth they’re doing). But originally, these rules were always paired with a set of log and anti-log tables. It was the combination of the rules and the tables which made logs so useful in the first place.

…they multiplied and divided using one of these.

Two sets of tables were needed: A log table, listing out values of $\log_b(x)$ for a given base $b$; and also an anti-log table, which listed out values of $b^m$ in the same base. For practical purposes, the base was almost always 10. Logs were given for values of $x$ from 1.0 up to 10, while anti-logs were given for values of $m$ from 0.0 to 1. Real log tables had far more elaborate designs which I’ll discuss in a later post, but for now, we’ll consider them to be simple lists of values like so
$\begin{array}{c|c} x & \log_{10}(x)\\ \hline 1.0 & 0.0000\\ 1.1 & 0.0414\\ 1.2 & 0.0792\\ 1.3 & 0.1139\\ 1.4 & 0.1461\\ 1.5 & 0.1761\\ 1.6 & 0.2041\\ 1.7 & 0.2304\\ 1.8 & 0.2553\\ 1.9 & 0.2788\\ 2.0 & 0.3010\\ 2.1 & 0.3222\\ \vdots & \vdots\\ 10.0 &1.0000 \end{array} \qquad \begin{array}{c|c} m & 10^m\\ \hline 0.00 & 1.000\\ 0.01 & 1.023\\ 0.02 & 1.047\\ 0.03 & 1.072\\ 0.04 & 1.096\\ 0.05 & 1.122\\ 0.06 & 1.148\\ 0.07 & 1.175\\ 0.08 & 1.202\\ 0.09 & 1.230\\ 0.10 & 1.259\\ 0.11 & 1.288\\ \vdots & \vdots\\ 1.00 &10.000 \end{array}$

Depending on how large you were prepared to make your tables (read. how much time and money you were prepared to spend), your tables could have finer increments for $x$ and $m$, give more decimal places for the logs and anti-logs, and supply extra corrections for additional accuracy. You could also dispense with tables altogether and use slide rules — devices which became an art in and of themselves.

We’ll just consider tables for now, and how they were used with each of the rules above. In what follows below, it will be assumed that we have access to a more finely graded set of tables such as

$\begin{array}{c|c} x & \log_{10}(x)\\ \hline 1.000 & 0.0000\\ 1.001 & 0.0004\\ 1.002 & 0.0009\\ 1.003 & 0.0013\\ \vdots & \vdots \end{array} \qquad \begin{array}{c|c} m & 10^m\\ \hline 0.0000 & 1.0000\\ 0.0001 & 1.0002\\ 0.0002 & 1.0005\\ 0.0003 & 1.0007\\ \vdots & \vdots \end{array}$

I: Logs turn multiplication into addition (plus lookups)

Now comes the power of logs. First we must cast our mind back to the days before calculators (There will be a payoff for the modern age later on). Suppose you needed to calculate the product of $4.89 \times 3.37$ to a relatively good approximation. You could just multiply things out, but that would take a bit and you’d need to be quick and accurate with your times tables.

Log tables offered a faster option. A quick lookup in the log table reveals that $\log_{10}(4.89)=0.6893$ and $\log_{10}(3.37)=0.5276$. Now, consider taking the log of the unknown product to the base ten, and applying rule I.
\begin{align*}
\log_{10}\brkt{4.89 \times 3.37} &= \log_{10}(4.89)+\log_{10}(3.37)\\
&\cong 0.6893+0.5276
\end{align*}
So it follows that approximately,
$\log_{10}\brkt{4.89 \times 3.37} \cong 1.2169$
We still don’t know what the product is, but taking the exponent of both sides and manipulating indices gives.
$4.89 \times 3.37 \cong 10^{1.2169} = 10^{0.2169} \times 10^1$
So the product is an integer power of $10$, times the mantissa $10^{0.2169}$. Looking up $10^m$ in the anti-log tables gives $10^{0.2169} \cong 1.647$ and so
$4.89 \times 3.37 \cong 1.647 \times 10^1= 16.47$
$4.89 \times 3.37 = 16.4793$
So we’ve obtained more or less the four most significant digits of the product without have to multiply anything at all. All we needed was three lookups, one addition, and a little index shifting. Since addition is much easier than multiplication, we can save ourselves a lot of effort and avoid many pitfalls, albeit at the cost of a little accuracy. Next comes division.

II: Logs turn division into subtraction (plus lookups)

Formidable mental calculators, and purists accustomed to 11 digits of digital accuracy might scoff at the meager gains afforded by combining the tables with rule I. The first group at least can be easily won over by applying rule II.

This time, let’s consider calculating the quotient $\frac{4.89}{3.37}$ to a relatively good approximation. We are still in the days before calculators, so a direct calculation will involve performing long division. Since we all remember long division from school, we’ll use logarithms instead. Using the same lookups from before, using log rule II gives
\begin{align*}
\log_{10}\brkt{\frac{4.89}{3.37}} &= \log_{10}(4.89)-\log_{10}(3.37)\\
&\cong 0.6893-0.5276\\
\end{align*}
Taking the exponent this time gives only a mantissa, which can be looked up directly in the anti-log tables.
$\frac{4.89}{3.37} \cong 10^{0.1617} \cong 1.451$
The result required three lookups and one subtraction. Carrying out explicit long division gives the quotient as being closer to
$\frac{4.89}{3.37} \cong 1.45103857566766$
So our log tables have again given us four significant of the result, and this time with much less work than a direct calculation. Subtraction is much easier than division.

And since in general long division of decimals gives only an approximate answer anyway, we haven’t lost much on principle either. We’re also much less likely to make a mistake in simple subtraction than in a long division. And if we need more digits, we can use the log approximation as an initial step in a faster division algorithm such as Newton’s method. All in all, logs and lookups are decisively outperforming pen and paper long division.

Simultaneous multiplication and division, or, “Life is Easier with Logs”

These methods really pay off if you need to multiply several numbers together, you’re only looking for approximate answers, and/or if you’re working in scientific notation away. Hence logs were extremely popular with engineers and anyone who just needed a “ballpark” answer. Suppose you need to calculate the following
$A=\frac{62830 \times 0.00931 }{23.15}$
At first it appears that all three numbers are outside the range of the standard $1$ to $10$ log table. However, writing the numbers in scientific notation, then using rule I and remembering that $\log_{10}(10^n) = n$, their logs can still be found using just the standard table.
\begin{align}
\log_{10}(62830) &= \log_{10}(6.2830 \times 10^5) = 4+\log_{10}(6.283) = 4.7982\\
\log_{10}(0.00931) &= \log_{10}(9.31 \times 10^{-3}) = -3+\log_{10}(9.31) = -2.0311\\
\log_{10}(23.15) &= \log_{10}(2.315 \times 10^1 = 1+\log_{10}(2.315) = 1.3646
\end{align}
Applying rules I and II simultaneously now gives the log of $A$ as
$\log_{10}(A) \cong 4.7982-2.0311-1.3646 = 1.4025$
And using the anti-log tables for the mantissa as before gives
$A\cong 10^{0.4025} \times 10^{1} = 25.26$
The true answer is closer to $A \cong 25.2677019438445$, but evidently life is a lot easier with logs.

Before moving on, I’ll quickly add the following calculation to show what happens if the logs ever add to a negative number. Suppose you wanted to calculate $B=23.15/62830$.
\begin{align}
\log_{10}(B) &\cong 1.3646-4.7982 = -3.4336\\
\Rightarrow B &\cong 10^{0.5664} \times 10^{-4} = 3.684 \times 10^{-4}
\end{align}

III: Logs turn powers/roots into multiplication/division (plus lookups)

But we’re still not done! Pre-calculator log based arithmetic could handle powers and roots as well. This is done by using log rule III — in conjunction with the tables of course.

Suppose you want to calculate $21.34^5$. Naturally, we don’t want to multiply things out. Applying rule III gives
$\log_{10}(21.34^5) \cong 5 \log_{10}(2.134 \times 10^1) = 5 \times 1.3292 = 6.646$
And so
$21.34^5 \cong 10^{0.646} \times 10^6 = 4.426 \times 10^6$
The true answer is exactly $4425599.1543363424$, so again logs are paying off, although we did need to multiply this time.

Next, lets try calculating a root(radix). Something neatly awkward like $\sqrt[7]{77.77}$, which is the same as $77.77^{1/7}$. Proceeding using Rule III as before gives
$\log_{10}(77.77^{1/7}) \cong \tfrac{1}{7} \log_{10}(7.777 \times 10^1) =\tfrac{1}{7} \times 1.8908 \cong 0.2701$
$\sqrt[7]{77.77} \cong 10^{0.2701} = 1.8625$
Which is accurate to four significant digits. This time we had to divide by $7$, but the result was well worth the price of this and only two look-ups.

It is difficult to overstate the impact of logarithms upon their arrival in the 1600’s. Their introduction made it feasible to calculate things like ratios, products, and cube roots on an everyday basis. But more on that later.

The power of logs lives on

To those accustomed to the power and flexibility of modern computers, the methods above may seem rather quaint. Today it is possible to perform all of the above on a pocket calculators, faster and more accurately than with any set of tables, and without needing to remember log rules or to shift indices about.

However the power of logs never really went away, and if we venture just a small way beyond ordinary calculations, we’ll find that logs are still a relevant arithmetical tool today. Consider the problem of calculating
$100! = 1 \times 2 \times 3 \times 4 \times \cdots \times 99 \times 100$
Most modern pocket calculators still fail to compute this number as the product grows beyond their capacity long before $100$ is reached(Those possessing the latest models or working on a computer system can simply consider calculating $1000!$ instead in what follows.). Still, we’d like to have some kind of estimate of $100!$. Is it bigger than $10^{100}$? $10^{200}$? $10^{1000}$? We can’t just give up at the first calculator error.

And so, just as in days of old, it’s logarithms which come to the rescue, turning multiplication into addition and making the problem tractable again. Taking the logs of both sides — now using the calculator/computer as our “tables” —  leads to the perfectly tractable sum
\begin{align}
\log_{10} 100! &= \log_{10} 1 + \log_{10} 2 + \log_{10} 3 + \cdots +\log_{10}100\\
&= 0+0.30103 + 0.47712+\cdots + 2 \cong 157.97
\end{align}
And so
$100! \cong 10^{0.97} \times 10^{157} = 9.3325 \times 10^{157}$
Specialised software exists that can compute the complete factorial, which turns out to be
\begin{align*}100! =
&93326215443944152681699238856266700490715968264381621468,\\
&59296389521759999322991560894146397615651828625369792082,\\
&7223758251185210916864000000000000000000000000
\end{align*}
And so simple logarithms can supply the correct order of magnitude and the first four significant digits of the result. The same procedure can estimate $1000!$ as
$1000! \cong 4.02387 \times 10^{2567}$
which should be enough to persuade almost anyone that logarithms still have a point to make in arithmetic. For any lingering doubters I leave the following estimates of one million and one billion factorial, obtained using logs and Stirling’s approximation
$1,000,000! \cong 8.2639 \times 10^{5565708}$
$1,000,000,000! \cong 9.9046 \times 10^{8565705522}$
I guarantee your pocket calculator won’t be able to do that!

So that’s a glimpse into the forgotten power of logarithms. Next time, I’ll discuss some of the history and impact of logs before describing the all important log tables and how to use them. Until next time.

This entry was posted in computation, logarithms. Bookmark the permalink.