A log by any other name

“Hey, Mr Moire?”

“Yes, Jeremy?”

“What we did with logarithms and exponents.  You showed me how my Dad’s slide-rule uses powers of 10, but we did that compound interest stuff with powers of 1.1.  Does that mean we could make a slide-rule based on powers of any number?”

“Sure could, in principle, but it’d be a lot harder to use.  A powers-of-ten model works well with scientific notation.  Suppose you want to calculate the number of atoms in 5.3 grams of carbon.  Remember Avagadro’s number?”

“Ohhh, yeah, chem class etched that into my brain.  It’s 6.02×10²³ atoms per gram atomic weight.  Carbon’s atomic weight is 12, so the atom count would be (5.3 grams)×(6.02×10²³ atoms / 12 grams), whatever that works out to be.”

“Nicely set up.  With the slide-rule you’d do the 5.3×6.02/12 part, then take care of the ten-powers in your head or on a scrap of paper.  It’d be ugly to do that with a slide-rule based on powers of π, for example.  Although, once you get away from the slide-rule it’s perfectly possible to do log-and-exponent calculations on other bases.  A couple of them are real popular.  Base-2, for instance.”2-10-e logs

“Powers of two?  Oh, binary!   2, 4, 8, 16, like that.  And 1/2, 1/4, 1/8.  Hard to imagine what a base-2 slide-rule would look like — zero at one end, I suppose, and one at the other and lots of fractions in-between.”

“Well, no.  Is there a zero on your Dad’s base-10 slide-rule there?”

“Uh, no, the C scale has a one at each end.”

“The left-hand ‘1’ can stand for one or ten or a thousand or a thousandth.  Whatever you pick for it, the right-hand ‘1’ stands for ten times that.”

“Ah, then a base-2 slide-rule would also have ones at either end in binary but they’d mean numbers that differ by a factor of two.  But there’d still be a bunch of fractions in-between, right?”

“Right, but no zero anywhere.  Why not?”

“Oh, there’s no power-of-two that equals zero.”

“No power-of-anything that equals zero.  Except zero, of course, but zero-to-anything is still zero so that’s not much use for calculating.  On the other hand, anything to the zero power is 1 so log(1)=0 in every base system.”

“You said a couple of popular bases.  What’s the other one?”

“Euler’s number e=2.71828…  It’s actually closely related to that compound interest calculation you did.  There’s several ways to compute e, but the most relevant for us is the limit of [1+(1/n)]n as n gets very large.  Try that on your spreadsheet app.”

“OK, I’m loading B1 with =(1+(1/C1))^C1 and I’ll try different numbers in C1.  One hundred gives me 2.7048, a thousand gives me 2.7169 (diminishing returns, hey) — ah, a million sure enough comes up with 2.71828.”

“There you go.  Changing C1 to even bigger values would get you even closer to e‘s exact value but it’s one of those irrationals like π so you can only get better and better approximations.  You see the connection between that formula and the $×[1+(rate/n)]n formula?”

“Sure, but what use is it?  If that’s the e formula the rate is 100%.”

“You can think of e as what happens when growth is compounded continuously.  It’s not often used in retail financial applications, but it’s everywhere in advanced math and physics.  I don’t want to get too much into that because calculus, but here’s one specialness.  The exponential function ex is the only one whose slope at every point is equal to its value there.”

“Nice.  But we’ve been talking logs.  Are base-e logarithms special?”

“So special that they’ve got their own name — natural logarithms, as opposed to common logarithms, the base-10 kind that power slide-rules.  They’ve even got their own abbreviations — ln(x) or loge(x) as opposed to log(x) or log10(x).”

“What makes them ‘natural’?”

“That’s harder to answer.  The simplest way is to point out that you can convert a log on one base to any other base.  For instance, ln(10)=2.303 therefore e2.303=10=101.  So log10 of any number x is 2.303 times ln(x) and ln(x)=log10(x)/2.303.  There are loads of equations that look simple and neat in terms of ln but get clumsy if you have to plug in 2.303 everywhere.”

“Don’t want to be clumsy.”

~~ Rich Olcott

Advertisements

Powers to The People

“You say logarithms and exponents have to do with growth, Mr Moire?”Log Exp and slide rule captioned

“Mm-hm.  Did they teach you about compound interest in that Modern Living class, Jeremy?”

“Yessir.  Like if I took out a loan of say $10,000 at 10% interest, I’d owe $11,000 at the end of the first year and, um…, $12,100 after two years because the 10% applies to the interest, too.”

“Nice mental arithmetic.  So what you did was multiply that base amount by 1+10% the first year and (1+10%)² the second, right?”

“Well, that’s not the way I thought of it, but that’s the way it works out, alright.”

“So it’d be (1+10%)³ the third year and in general (1+rate)n after n years, assuming you don’t make any payments.”

“Sure.”

“OK, how do we have to revise that formula if the interest is compounded daily and you get lucky and pay it off in a lump sum after 19 months?”

“Can I use your whiteboard?”

“Go ahead.”

“OK, first thing to change is the rate, because the 10% was for the whole year.  We need to use 10%/365 inside those parentheses.  But then we’re counting time by days instead of years.  Each day we multiply the previous amount by another (1+10%/365), which makes the exponent be the number of days the loan is out, which is 19 times whatever the average number of days in a month is.”

“Why not just use 19×(365÷12)?”

“Can we do that?  In an exponent?”

“Perfectly legal, done in all the best circles.”

“So what we’ve got is
10000×[1+(10%/365)]19×(365÷12).

“Try poking that into your smartphone’s spreadsheet app and format it for dollars.”

“In spreadsheet-ese that’d be
=10000*(1+(0.1/365))^(19*(365/12)).
Hah!  The app took it, and comes up with … $11,715.31.  Lemme try that with two years that’s 24 months.  Now it’s $12,213.69.  Hey, that’s $123 more than two years compounded once-a-year.  Compounding more often generates more interest, doesn’t it?”

“Which is why daily compounding is the general rule in consumer lending.  But there’s a couple more lessons to be learned here.  One, you can do full-on arithmetic inside an exponent.  That’s what the log log scales are for on a slide rule.  Two, the expression you worked up has the form
base×(growth factor)(time function).
Any time you’re modeling something that grows or shrinks in some percentage-wise fashion, you’re going to have exponential expressions like that.”

“Hey, I tried compounding more often and it didn’t make much difference.  I put in 3650 instead of 365 and it only added 30¢ to the total.”

“Which gives me an idea.  Load up cells A1:A7 in your spreadsheet with this series: 1, 3, 10, 30, 100, 300, 1000.  Got it?”

“Ahhh … OK.  Now what?”

“Now load cell B1 with +10000*(1+(0.1/A1))^(24*(A1/12)).”

“Says $12,100.”

“Fine.  Now copy that cell down through B7.”

“Hmm…  The answers go up but by less and less.”

“Right.  Now highlight A1:B7 and tell your spreadsheet to generate a scatter plot connected by straight lines.”

“Gimme a sec … OK.  The line goes straight up, then straight across almost.”

“Final step — click on the x-axis and tell the program to use a logarithmic scale.”diminishing returns

“Hey, the x-numbers scrunch and wrap like on the A, B and K scales on Dad’s slide-rule.”

“Which is what you’d expect, right?  They both use logarithmic scales.  The slide-rule uses logarithms to do its arithmetic thing.  The graphing software lets you use logarithms to display big numbers together with small numbers.  But the neat thing about this graph is that it shows two different flavors of a general pattern.  Adding something, say 20, to a number to the left on the x-axis moves you a longer distance than adding the same amount somewhere over on the right.  That’s diminishing returns.”

“Look, the heeling-over curve shows diminishing returns from compounding interest more and more often.”

Exploding returns“Good.  Now copy A1:A7 by value into C1:C7 and generate a scatter plot of B1:C7. This time apply the logarithmic scale to the y-axis. This’ll show us how often we’d need to compound to get the yield on the x-axis.”

“Whoa, it blows up, like there’s no way to get up to $12,300.”

“Call it exploding returns.  Increasing the exponent increases the growth factor’s impact.  Beyond a threshold, a small change in the growth factor can make a huge difference in the result.”

“Seriously huge.”

“Exponentially huge.”

~~ Rich Olcott

Log-rhythmic gymnastics

I recognized the knock.  “Come on in, Jeremy, the door’s open.”

“Hi, Mr Moire.  Can you believe this weather?  Did Miss Anne like her gelato?  What’s this funny ruler thing that my Dad sent me?  He said they used it to send men to the moon.”

log rhythm

“No, yes, it’s called a slide rule, and he’s right — back in the 1960s engineers used slip-sticks like that when they couldn’t get to a four-function mechanical calculator.  Now, though, they’re about as useful as a cast-iron bath towel.  Kind of a shame, because the slide rule is based on mathematical principles that are fundamental to just about all of mathematical physics.”

“Like what?”

“The use of exponents, for one.  Add exponents to multiply, subtract to divide.  Quick — what’s 100×100×100?”

“Uhh…  Ten million?”

“Nup.  But if I recast that as 102×102×102=102+2+2?”

“106.  Oh, that’s a million.”

“See how easy?  We’ve known that kind of arithmetic since Archimedes.  The big advance was in the early 1600s when John Napier realized that the exponents didn’t have to be integers.  Take square roots, for example.  What’s the square root of 100?”

“Ten.”

“Sure — √100=√(102)=102/2=101=10.  Now write √10 with exponents.”

“Would it be 101/2?”

“Let’s see.  Do you have a spreadsheet app on that tablet you carry?”

“Sure.”

“OK, bring it up.  Poke =10^(0.5) into cell A1, and =A1^2 into A2.  What do you get?”

“Gimme a sec … the first cell says 3.162278 and the second says … exactly 10.”

“Or as exact as that software is set up for.  So what we’ve got is that 0.5 is a perfectly good power of ten, and exponent arithmetic works the same with it and all the other rational numbers that it does with integers.  Too big a leap, or are you OK with that?”

“OK, I suppose, but what does that have to do with this gadget getting people to the Moon?”

“Take a good look at at the C scale, the lowest one on the middle ruler that slides back and forth.  Are the numbers evenly spaced out?”

“No, they’re stretched out at the low end, scrunched together at the high end.”Slide rule 3“Look for 3.16 on there.  You read it like a ruler — the number before the decimal point shows as a digit, then you locate the fractional part with the high and low vertical lines.”

“Got it.  About halfway across.”

“It’s exactly on center if that’s a good slide rule.  A number’s distance along the scale should be proportional to the exponent of 10 (we call it the logarithm) that gives you that number.  The C scale’s left end is 1.0, its right end is 10.0, and 3.162 is halfway.”

“Ah, I see how it works.  Adding distances is like adding exponents.  So if I want to multiply 2 by 3 I slide the middle ruler until its 1 is against 2 on the D scale, then I look for 3 on the C scale and, yes! it’s right next to 6 on the D scale!  Oh and the A and B scales wrap twice in the same distance so they must be logarithms for squares?  Hah, there’s 10 on B right above where I found 3.16 on CK wraps three times so it must be cubes, but why did they call it K?”

“Blame the Germans, who spell ‘cube‘ with a ‘k‘.  What do you suppose CI does?”

“Hmm, it runs backwards.  Adding with CI would be like subtracting distances which would be like dividing, so … I’ll bet it’s ‘C-Inverse‘!”

“You win the mink-lined frying pan.  So you see how even a simple 5- or 6-scale device can do a lot of calculation.  The really fancy ones had as many as a dozen scales on each side, ready for doing trigonometry, compound interest, all kinds of things.  That’s the quick compute power the rocket engineers used back in the 50s.”

“Logarithms did all that, eh?”

“Yup, that and the inverse operation, exponentiation.  Of course, you don’t have to build your log and exponent system around 10.  If you’re into information theory you might use powers of 2.  If you’re doing physics or pure math you’re probably going to use a different base, Euler’s number e=2.71828.  Looks weird, but it’s really useful because calculus.”

“So logarithms do calculating.  You said something about physical principles?”

“Calculating growth, for instance…”

~~ Rich Olcott