Fond memories

Let me tell you about a greeting from the past I recently found…

When digging through old files, I happened to find a record of the first computer program that I have ever written. This was back in 1973, I believe, but it could also have been 1974; I was 13 or 14 years old back then.

The program ran on a Diehl Combitron S, a very early programmable (of sorts) desk top computer. It could do fixed point calculation, and calculate square roots, on top of the obvious +, -, ×, and ÷.

My home-brew algorithm taught it to calculate (decadic) logarithms. And the reverse, of course (which is my second program ever).

Here’s a scan of a contemporary copy of the original record. I think I did the original coding with pencil. Then, on a Saturday, we went to my dad’s workplace to try out my program: Have it calculate log(2).

The computer sat there, humming, and printed nothing.

Dad became suspicious: “These programs never run that long! Something must be wrong!” I went through my code again and found I had indeed gotten one of the conditional jumps wrong. This resulted in an endless loop.

After correction, the same story: Again the computer sat there, humming, printing nothing. Again dad started to voice his doubts. Again I was busy staring at and thinking through my code - when suddenly, the computer’s noisy printer startled us, springing to life and giving the correct answer. It just took a while! (Maybe three minutes for one logarithm, or so?)

Here comes my documentation from the 70s. The logarithm part is at the left, the “ten to the power of” at the right. The code must be read in columns rather than rows.

Scan of my original manuscript

Some 40+ years later, I remember the simple code well enough to translate it to Python. This is not intended to be elegant Python, but to faithfully reflect the original algorithm (and give explanations).

#!/usr/bin/env python3

import sys
import math

k5 = 2
k6 = 10000
k7 = 4
k8 = 0
k4 = k8 # Implicit after switch-on of original machine.

# The smallest number that makes a difference when added to 1
# in the original Diehl Combitron S back in 1973
# is substituted with the smallest such number in Python today:
k9 = sys.float_info.epsilon

while True:
    k1 = float(input("log > "))

    # Invariant A of the algorithm:
    # k2 is some number with known log, and k3 is that log.
    # We'll see to it that k3 becomes closer and closer to 0.
    k2 = k6
    k3 = k7

    while True:
        if 0 <= -k1 + k2 - k9:
            # Invariant B of the algorithm:
            # If k1_original is the original value of k1,
            # then log(k1_original) = log(k1) + k4 .
            # We'll see to it that k1 becomes closer and closer to 1,
            # so k4 will become closer and closer to log(k1_original)
            k1 = k1 / k2
            k4 = k3 + k4

        # Keep invariant A,
        # but let k2 converge to 1 and k3 to 0:
        k2 = math.sqrt(k2)
        k3 = k3 / k5

        # This termination condition made sense
        # on the fixed-point machine, but it still works
        # (though it's somewhat wasteful) with today's floats:
        if 0 <= -k3:

    # Print the logarithm

    # Prepare for next iteration.
    k4 = k8

Some remarks:

Dr. Andreas Krüger, Herweghstr. 13, 12487 Berlin, Germany,