I converted this into python to understand it better
def log10(x):
"""
Find 10 decimal places of log10(x) using calculator functions only
"""
assert x > 0, "can't log <= 0"
log = 0
while x >= 10:
log += 1
x /= 10
while x < 1:
log -= 1
x *= 10
# x is now [1, 10)
decimal = 0.1
for i in range(10):
x10 = x**10 # or calculate as above so as not to use power function
while x10 >= 10:
log += decimal
x10 /= 10
x = x10
decimal /= 10
print(f"log10(x) = {log:.10f}, x = {x:.10f}")
log10(3)
Which gives log10(x) = 0.4000000000, x = 5.9049000000
log10(x) = 0.4700000000, x = 5.1537752073
log10(x) = 0.4770000000, x = 1.3220708195
log10(x) = 0.4771000000, x = 1.6313501853
log10(x) = 0.4771200000, x = 1.3349714142
log10(x) = 0.4771210000, x = 1.7977101167
log10(x) = 0.4771212000, x = 3.5253044107
log10(x) = 0.4771212500, x = 2.9646009506
log10(x) = 0.4771212540, x = 5.2439970092
log10(x) = 0.4771212547, x = 1.5726220230On the other hand, (hand-waving) it takes many generated digits before the “far away” get shifted left of the decimal point, so numerical analysis probably can show you don’t need them all to reach a target number of digits.
I have in the past, this time I used the 4 function calculator mode of Windows 10's calculator. x^2, MS, x^2, x^2 * MR = on the loops, then divide by 1+n zeros, repeat.
I used NotePad++ to record the data as I went.
Doing it for a binary logarithm would be a lot easer, because then it's square and optionally divide by 2.
AFAIK, that calculator has “Infinite precision for basic arithmetic operations (addition, subtraction, multiplication, division) so that calculations never lose precision” (https://github.com/microsoft/calculator)
For log10....