Pretty image
A different sort of log for the new year.

I’ve been rereading Nero Wolf lately. The writing is crisp, the language imaginative, and the setting is refreshing. The fictional detective mostly stays in his home and uses his wits to solve crimes. Archie Goodwin, his assistant, does most of the legwork.

And it is legwork, not webwork. The author, Rex Stout, died in 1978, so his books are definitely dated. Neither Wolfe nor his rivals in the police department have the technology or the resources you’ll find on your modern murder mystery shows like CSI and Law & Order. Wolf uses words like “flummery” and “pfui” and doesn’t have access to the internet or to DNA testing. When Archie is out running down clues he doesn’t have a cell phone where people can reach him. He has to go find a pay phone or borrow one.

But that’s part of the charm of the stories. Sure, we benefit from our modern conveniences, but it’s nice to step back and enjoy a story set in a simpler time.

It reminds me of math before calculators. I can do a whole lot more in math now than I could do thirty-some years ago, but I still fondly remember using log tables and slide rules to perform quick calculations. In this month’s column, let’s go back to that simpler time.

Decoder Ring

We’re not going to go deep into logarithms. For this article we’ll use common logs (logs base 10) but you don’t really need to know what that means. We need a log table—here’s one I created with the spreadsheet program Numbers.

getalife/CommonLog.jpg

If you want the log for 3.14, for example, you read down the left column until you find 3.1 and then you read across the top until you find .04. The cell that is in the same row as 3.1 and the same column as .04 is .4969. To four digits, the log of 3.14 is .4969.

So here’s fun fact number one: log a + log b = log ab. In words, the log of a product is the sum of the logs. I kind of think of the log table as a decoder ring—here’s how you use it to multiply 2 and 3 using logs.

  1. Encode: In the table you can see that log 2 = .3010 and log 3 = .4771.

  2. Calculate: log 2 + log 3 = .3010 + .4771 = .7781

  3. Decode: Look through the entries in the log table until you find something close to .7781. The closest I find is .7782 which is the log of 6.00.

After much work you’ve discovered that 2 * 3 = 6.

You can deduce from our first fun fact that log a/b = log a - log b. In words, the log of a quotient is the difference of the logs.

Place Value

Before we move on, take another look at the log table. The encoded values are between 0 and 1. So the numbers you can take the log of are between 1 and 10. And that’s all you need, but you’ve got to take care of place value for yourself.

For example, suppose you want to leave a 15% tip on a meal that costs $4.75. You need to multiply .15 by 4.75. You can’t look up .15 in the table but you can look up 1.5. So to calculate the tip like this. log 1.5 + log 4.75 = .1761 + .6767 = .8528. In the table .8528 is smack dab in the middle of 7.12 and 7.13. Remember, it’s up to you to keep track of the place value. 15% of $4.75 can’t be $7.12 it has to be closer to 71 cents.

Constructing a Slide Rule

getalife/SlideRuleTemplate.jpg

Logs let you replace multiplication and division with addition and subtraction, plus some encoding and decoding. A slide rule lets you forget about the encoding and decoding steps.

To make your own slide rule, you’ll need an 8 1/2 x 11 sheet of paper, a ruler, and a pencil. Turn the paper on its side and draw a horizontal line that is exactly 10 inches long. Draw a vertical line at each end and label it 1, top and bottom, left and right, like this.

Measure 3.01 inches from the left mark and make another vertical mark and label it above and below the line as 2. This comes from our table since log 2 = .3010. Similarly, make another mark that is 4.77 inches from the left and label it 3. We’ll fill in the rest of the numbers except 7 using the rules of logarithms. For 7 make a mark that is 8.45 inches from the left.

For the final step, carefully cut along the horizontal line. You now have a slide rule.

Multiplying on your slide rule

Take the top half of the slide rule and slide it to the right so that the left 1 sits on top of the 2.

getalife/SlideRuleTemplateDouble.jpg

Look under the 3. Mark it with a 6. Can you see that it is what you get when you add the distance from 1 to 2 to the distance from 1 to 3? Without any tables, you can read off that log 6 = log 2 + log 3. While you’re at it add a mark for 4 under the 2.

getalife/SlideRuleTemplateDoubleAfter.jpg

I’ve lined the two halves back up and made the marks for 4 and 6 on the upper scale as well. You should be able to figure out where the marks for 8 and 9 go. 8 is 2 * 4 and 9 is 3 * 3.

Running out of room

You should have figured out where 9 is by moving the top left 1 over the 3. The 9 should go directly under the mark for the 3. You can also see that the 6 sits directly under the 2, as 2 * 3 = 3 * 2.

getalife/SlideRuleTemplateTriple.jpg

How would we multiply 3 * 4?

If our past pattern holds we should look underneath the 4 on the top scale and that’s where the 12 should go. Unfortunately, this is past the end of the bottom half of the slide rule. So here’s another fun fact: when you run out of room using the 1 on one end of the scale, just use the 1 at the other end of the scale.

In this case, line up the 1 that is at the right end of the top scale with the 3 on the bottom scale. Now when you look for the 12 below the 4 you’ll find it between the 1 and the 2 on the bottom scale. This is correct once you realize that you’re actually getting 1.2 and it’s up to you to remember that it should be 12, not 1.2.

getalife/SlideRuleTemplateTwelve.jpg

Dividing

We can’t use multiplication to place the 5. We need to use the fact that 10/2 = 5. So we subtract log 2 from log 10 to locate the 5. For log 10 we use the 1’s on either end of scale. I’ve set it up like this:

getalife/SlideRuleTemplateFive.jpg

I lined the 2 in the top scale up with the 1 on the right side of the lower scale. So the 5 should go under the 1 on the left side of the top scale. This arrangement subtracts the log 2 from log 10.

And that’s it. You’ve created a nice slide rule and you can keep adding to it to fill in more values that you need. I’m not saying you should discard your calculator in favor of log tables and slide rules. That’s flummery. I am saying that it’s fun now and then to remember that we can. And I also think it’s a great way to reconnect to some of the underlying math that we don’t think about much anymore.

Share your slide rule experiences with Daniel and other readers in the magazine forum. -Mike

Daniel is the editor for the new series of Mac Developer titles for the Pragmatic Programmers. He writes feature articles for Apple’s ADC web site and is a regular contributor to Mac Devcenter. He has presented at Apple’s Worldwide Developer Conference, MacWorld, MacHack, and other Mac developer conferences. Daniel has produced podcasts for Apple featuring the work of developers and scientists working on the platform. He has coauthored books on Apple’s Bonjour technology as well as on Java Programming and using Extreme Programming in Software Engineering classes.