How Does a Calculator Find Log?Date: 03/23/98 at 11:43:21 From: CMLee Subject: How does a calculator find log? My teacher has told me that there is no specific formula to derive logarithms in decimal form. I was wondering if this was true. If it is, then how does a calculator or computer perform calculations to find approximations of particular logs, say log5. Also where are the tables of logarithms derived from? Date: 03/23/98 at 13:07:05 From: Doctor Rob Subject: Re: How does a calculator find log? There are infinite sums which give the values of logarithms. Examples are the following: log_e(1+x) = x - x^2/2 + x^3/3 - x^4/4 + x^5/5 - x^6/6 + ... (-1 < x < 1) log_e([n+1]/[n-1]) = 2/n + 2/(3*n^3) + 2/(5*n^5) + 2/(7*n^7) + ... In particular, to find the log of 5 base e, you can use the first equation with x = -4/5 to compute the log of 1/5, and the log of 5 is the negative of that answer. The terms in these sums get very small after a while, particularly if the value of x is small, or the value of n is large. To approximate a logarithm to a certain accuracy, you only need to compute a finite number of these terms. The smaller x is, the fewer terms are needed. To compute log_e(2) to four decimal places of accuracy, put n = 3 in the second sum, and use the first four terms. The fifth term is about .00001129, the sixth term .000001026, and subsequent terms are even smaller, so ignoring them does not affect the approximate answer. Once you know log_e(2), you can get log_e(5) by using the first sum with x = 1/4 and 11 terms, to get log_e(5/4), then add twice log_e(2). Then log_e(5) + log_e(2) = log_e(10). This is the conversion factor you need to convert to log_10(x): log_10(x) = log_e(x)/log_e(10). This is how the logarithm tables are computed, and basically how electronic calculators compute, too. One strategy is to have precomputed and stored log_e(2) and log_e(10). Divide your number by 2 until it is between 2/3 and 4/3, say k divisions are required. Alternatively, multiply your number by 2 until it is between 2/3 and 4/3, say (-k) multiplications are needed. Use the first sum above with x equal to that result minus 1 (which is between -1/3 and 1/3), then add k*log_e(2) to that answer. Finally, divide by log_e(10). Another way to approximate the logarithm of a given number is to use the square root function and the definition of log_10(x) as the exponent to which 10 must be raised to get x. As an example let's take log_10(5). We know log_10(10) = 1, which is too large, and log_10(1) = 0, which is too small. log_10(sqrt[10]) = 1/2, and we can compute 10^(1/2) = sqrt(1*10) = 3.16227766..., too small. Then since sqrt(10) < 5 < 10, we know that 1/2 < log_10(5) < 1. Now compute: 10^(3/4) = sqrt[10*sqrt(10)] = 5.52341325... > 5, too big. This implies that 1/2 < log_10(5) < 3/4. We started with an interval of length 1. Each square root computation has cut the length of the interval in which we know log_10(5) lies in half. After two square roots, we have an interval of length 1/4. Eventually we will have an interval which is smaller than 1/10000 (at least 14 square roots are required), and that will tell us log_10(5) to four decimal places: 10^0 = 1, too small, 10^1 = 10, too big, 10^(1/2) = 3.16227766..., too small, 10^(3/4) = 5.52341325..., too big, 10^(5/8) = 4.21696503..., too small, 10^(11/16) = 4.86967525..., too small, 10^(23/32) = 5.23299114..., too big, 10^(45/64) = 5.04806571..., too big, 10^(89/128) = 4.95806824..., too small, 10^(179/256) = 5.00286461..., too big, 10^(357/512) = 4.98041606..., too small, 10^(715/1024) = 4.99162771..., too small, 10^(1431/2048) = 4.99724300..., too small, 10^(2863/4096) = 5.00005301..., too big, 10^(5725/8192) = 4.99864781..., too small, 10^(11451/16384) = 4.9993503..., too small, 10^(22903/32768) = 4.9997016..., too small, 10^(45807/65536) = 4.9998773..., too small, So 45807/65536 = 0.6989593 < log_10(5) < 0.6989746 = 2863/4096. Thus, to five decimal place, log_10(5) is either 0.69896 or 0.69897, and to four decimal places, log_10(5) = 0.6990, which your calculator or tables can verify. The pattern in the fractions above is that the denominator doubles at each step, and the numerator is double plus 1 if the previous answer was too small, and double minus 1 if the previous answer was too big. Each power of 10 is computed as the square root of the product of the last "too big" power times the last "too small" power. I hope this answers your question. -Doctor Rob, The Math Forum Check out our Web site http://mathforum.org/dr.math/ |
Search the Dr. Math Library: |
[Privacy Policy] [Terms of Use]
Ask Dr. MathTM
© 1994- The Math Forum at NCTM. All rights reserved.
http://mathforum.org/dr.math/