Imagine you are living a lot of years ago, without calculators, slide rules, tables of logarithms, or any kind of tool but paper and pencil... how would you go about calculating log
10 of 2 -- or of any other number?
By the way, if your solution required calculating powers, or if you just wanted to check your solution, how would you calculate 10 to the 0.30103... power, or any other?
(In reply to
put another way by Charlie)
Nice detailed explanation, Charlie.
Just because we are imagining that we have no mechanical aids or tables, there is no reason we can't use a program to do the dog work. And amazingly, the primitive algorithm runs fairly quickly when implemented in QBASIC. Here is the code:
DEFINT H-Q: DEFDBL A-G, R-Z
WHILE 1
PRINT "Enter X and press ENTER": INPUT X: PRINT " X ="; X
IF X < 1 THEN END
B = 10&
IF X >= B THEN END
Y = 1&: W = 0&: T = 1&
R = SQR(B): PRINT "."; :
FOR I = 1 TO 60
Z = Y * R: T = T / 2&
IF Z <= X THEN Y = Z: W = W + T: PRINT "1"; : ELSE PRINT "0"; :
R = SQR(R)
NEXT
PRINT
PRINT W, Y
WEND
For 2 as input the output is
.010011010001000001001101010000100111110111100111111111111111
.3010299956639813 2
if I have copied it down correctly. The last 20 bits may well not be accurate.
Edited on July 26, 2004, 11:34 pm
|
Posted by Richard
on 2004-07-26 23:30:13 |