Converting Logs to Another Base
Date: 04/27/98 at 01:50:52 From: Ashraf Suleman Subject: Finding the nth log Hello, I'm taking a computer programming course in Grade 12 (Pascal), and on the side I've decided to write a calculator program for use in DOS. The compiler I'm using, however, only performs logarithms to the base e. How can I use it to find log to the base 10, or log to the base n (if possible)? I don't need the specific programming code, just the method I would use is sufficient. I've searched through the site here but I haven't found anything pertaining to this (I've yet to take algebra, calculus, or finite, so I don't have a grasp of many of the terms). Any help would be greatly appreciated. Thanks :)
Date: 04/27/98 at 07:41:37 From: Doctor Jerry Subject: Re: Finding the nth log Hi Ashraf, If you want y = log_a(w), then: a^y = w ln(a^y) = ln(w) y*ln(a) = ln(w) y = log_a(w) = ln(w)/ln(a) -Doctor Jerry, The Math Forum Check out our web site! http://mathforum.org/dr.math/
Date: 04/29/98 at 07:44:14 From: Doctor Bradley Subject: Re: Finding the nth log There is a nice way of converting logarithms from any base to another. This is very useful, as you have found in trying to write your program. Before showing you the rule for conversion, let me show you one way to obtain it so that you can see how and why it works. Let's suppose you want to find the log base n of x; call this y: y = log x n What this really means is that x = n^y. Now suppose I am your computer and can only take logarithms using the base e. I could take the base e logarithm of both sides of the equation x = n^y; this would give me: ln x = ln (n^y) Writing "ln" means "log base e". Next we make use of the property of logarithms which says that ln (n^y) = y * ln (n), so our equation becomes: ln x = y ln n Now we divide both sides by ln n to get: (ln x)/(ln n) = y Remember that y is the original logarithm we wanted to find using base n, so all we have to do is take the natural (base e) log of x and divide by the natural log of n. This conversion rule works for any base, not just e; the general rule to convert from base n to any base b looks like this: log x = (log x)/(log n) n b b Hope this helps. Good luck with your programming! -Doctor Bradley, The Math Forum Check out our web site! http://mathforum.org/dr.math/
Search the Dr. Math Library:
Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.