Big Data/Analytics Zone is brought to you in partnership with:

John Cook is an applied mathematician working in Houston, Texas. His career has been a blend of research, software development, consulting, and management. John is a DZone MVB and is not an employee of DZone and has posted 171 posts at DZone. You can read more from them at their website. View Full User Profile

The Most Interesting Logs in the World

11.20.2012
| 4761 views |
  • submit to reddit

I occasionally get a comments from people who see “log” in one of my posts and think “log base 10.” They’ll say they get a different result than I do and ask whether I made a mistake. So to eliminate confusion, let me explain my notation.

When I say “log,” I always mean natural log, that is, log base e. This is the universal convention in advanced mathematics. It’s also the convention of every programming language that I know of. If I want to use logarithms to a different base, I specify the base as a subscript, such as log10 for log base 10.

The reason logs base e are called natural, and the reason they’re most convenient to use, is that base e really is natural in a sense. For example, the function kx is its own derivative only when k = e. And the derivative of logk(x) is 1/x only when k = e.

All logarithms are proportional to each other. That is, logb(x) = loge(x) / loge(b). That’s why we can say something is logarithmic without specifying the base. So we might as well pick the base that is easiest to work with, and most people agree that’s base e. (There are some exceptions. In computer science it’s often convenient to work with logs base 2, sometimes written lg.)

Logarithms base 10 have the advantage that they’re easy to compute mentally for special values. For example, the log base 10 of a 1,000,000 is 6: just count the zeros. So it’s good pedagogy to introduce logs base 10 first. But natural logs are simpler to use for theoretical work, and just as convenient to compute numerically.

Along these lines, when I use trig functions, I always measure angles in radians. Just like all advanced mathematics and all programming languages.

As with natural logs, radians are natural too. For example, the derivative of sine is cosine only when you work in radians. If you work in degrees, you pick up a proportionality constant every time you differentiate a trig function.

Natural logs and radian measure are related: Euler’s formula eix = cos(x) + i sin(x) assumes the base e and assumes that x measured in radians.

Published at DZone with permission of John Cook, author and DZone MVB. (source)

(Note: Opinions expressed in this article and its replies are the opinions of their respective authors and not those of DZone, Inc.)

Comments

Stas Ostapenko replied on Tue, 2012/11/20 - 9:00am

 http://en.wikipedia.org/wiki/Natural_logarithm

log_{e}(x) =ln(x)

Alan Hampson replied on Wed, 2012/11/21 - 1:11pm

 John, I normally agree with your columns, but I have to disagree here. According to my memory and college algebra book (College Algebra, Kolman & Shapiro, 1981), "The notation ln x is used to indicate logarithms to the base e. We call ln x the natural logarithm of x."

I also recall that log with no subscript was always log base 10. That's how it's been for me as long as I can remember.

You are correct about the log function in programming languages (at least for Java and C++). This is an oddity that I never noticed. But even in the C++ reference , the example code has this:

printf ("ln(%lf) = %lf\n", param, result );

using ln for the natural log notation in the output (emphasis mine).

I really do enjoy reading your work, both here and at The Endeavour. Sorry that my first comment to you is critical, but a big THANKS for all you do.

alan


Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.