From: rusin@vesuvius.math.niu.edu (Dave Rusin) Subject: Re: Logarithm Questions Date: 13 Oct 2000 06:21:44 GMT Newsgroups: sci.math Summary: [missing] In article , HollyKing wrote: >Second, how could I calculate a logarithm. Sure, my calculator can do >common and natural logarithms and I can look logarithms for other bases up >in tables. However, someone had to calculate the tables. How do they do >that? Your calculator uses a number of tools developed with the aid of calculus. These give the "right" answers. But you can do pretty well estimating these on your own. I worked out some examples for someone who asked a similar question a couple of months ago here. Here's an abridged version of my comments at that time. dave >In other words, if one were on a desert island -- even with a hand >calculator, but one that didn't have a "log" button -- and Mr. Selkirk >had not left a copy of Napier's classic 1616 paper, how would one find >the common logs of say, the numbers 2-9? Know some nice round products: 3^2 = 9 ~ 10 so then log(3) ~ 0.5 (You said _common_ logs, right?) 2^10 = 1024 ~ 10^3, so 2 ~ 10^(3/10), so log(2) ~ 0.3 5 = 10/2 so then log(5) ~ 0.7 7^2 = 49 ~ 50 = 10^1 x 5 so then log(2) ~ (1.7)/2 = 0.85 Get the others by multiplying, e.g. log(6) = log(2) + log(3). Of course, "9~10" is a poor approximation, which is why we only get log(3)~.5 instead of log(3)=0.47712... If you want a better approximation to log(3), you need a better approximation than "9~10" but one which still involves powers of 3 and 10. If you happened to know that e.g. 3^153 = 9989689...23 (a total of 73 digits) ~ 10^73 then you'd know that log(3) was given more accurately by 73/153=0.477124... (it's actually 0.477121...). Likewise with 7^510=1000000937776...5249 (a total of 432 digits) and 2^2136 ~ 10^643 . It is easy to generate these "amazing coincidences" ex post facto: if you know log(3) to great accuracy, you may compute the continued-fraction approximants to this, and get an infinite sequence of pairs (a,b) of integers with the property that the ratios 3^a/10^b approach 1, starting with 3^2/10^1. Well, "ex post facto" is not a good desert-island method, I admit, but it's not all that bad either. So far I have only used the fact that two nearby numbers can have only 3's and 10's in their prime factorizations. We can get better approximations for logs by finding some very close numbers with simple factorizations. It pays to use these to compute several logs at once. For example, there are many easy-to-find pairs of consecutive numbers all of whose prime factors are among 2, 3, 5, 7, 11: examples are {n, n+1} where n=120, 125, 175, 224, 242, 384, 440, 539, 2400, 3024, 4374, 9800... In each case, we may expand the statement log(n+1) - log(n) ~ 0 into a linear combination of log(2), ..., log(11). Here are a few of them: 2 log(11) - 3 log(2) - log(3) - log(5) ~ 0 5 log(3) - log(2) - 2 log(11) ~ 0 4 log(7) - 5 log(2) - log(3) - 2 log(5) ~ 0 4 log(5) + log(7) - log(2) - 7 log(3) ~ 0 Substitute log(5) = 1-log(2), treat "~" as "=", and solve. I get log(2) ~ 45/149~0.302, log(3) ~ 71/149 ~ 0.477, log(7) ~ 126/149 ~ 0.846 and log(11) ~ 155/149 ~ 1.040. All these answers are off by at most 0.001. So you see you can trade off a little, and consider smaller numbers (than 2^huge) but with more unknown values taken at once. You want better approximations? Take only large pairs {n, n+1}, including if necessary a few more prime divisors. (A familiar example: n=10^3, with 1001 = 7*11*13.) You had asked for desert-island mathematics, so I assumed you wanted only rough approximations for the values of the logs. The theory is good for arbitrary generality, but of course the work gets prohibitive. Naturally, there are other methods you could use if your desert island included a programmable calculator: If you have a nearby number N whose log is known, then you can compute log(x) = log(N) + log(x/N) = log(N) + log(1 + (x-N)/N). The last can be computed e.g. by log(1 + t) = t - t^2/2 + t^3/3 - ... ; continue until tired. If I were writing programs, I guess that's what I'd do. If I were on an island, or stuck in the 16th century, I might really go the route shown earlier. dave ============================================================================== Checking primes thru 13 on pairs {n, n-1} with n < 350 000: good n= [10, 11, 12, 13, 14, 15, 16, 21, 22, 25, 26, 27, 28, 33, 36, 40, 45, 49, 50, 55, 56, 64, 65, 66, 78, 81, 91, 99, 100, 105, 121, 126, 144, 169, 176, 196, 225, 243, 325, 351, 352, 364, 385, 441, 540, 625, 676, 729, 1001, 1716, 2080, 2401, 3025, 4096, 4225, 4375, 6656, 9801, 10648, 123201] Checking primes thru 23 on pairs {n, n-1} with n < 1 250 000: good n= [smalls, 8625, 9801, 10241, 10626, 10648, 10830, 11271, 11662, 12168, 12376, 12636, 13377, 14080, 14365, 14400, 16929, 19551, 21505, 21736, 23276, 23409, 25025, 25921, 27456, 28561, 28900, 31213, 37180, 43264, 43681, 52326, 71875, 75141, 76545, 89376, 104329, 104976, 122452, 123201, 126225, 152881, 165376, 194481, 202125, 228096, 264385, 282625, 328510, 336141, 601426, 633556, 709632] so e.g. last seven plus the one for 194481 give equations from which to deduce log(p) for p=3,5,7,11,13,17,19,23 (and log(5) = 1 - log(2).): all are fractions over 55835, roughly l2 = 0.3010298200 true = .3010299957 l3 = 0.4771200860 true = .4771212549 l5 = 0.6989701800 true = .6989700041 l7 = 0.8450971613 true = .8450980400 l11 = 1.041389809 true = 1.041392685 l13 = 1.113942867 true = 1.113943352 l17 = 1.230446852 true = 1.230448921 l19 = 1.278749888 true = 1.278753601 l23 = 1.361726516 true = 1.361727836