Skip to content

a taste of programming the Mark I

 

Besides containing math that helped to advance work on the Riemann Hypothesis, Turing’s paper “Some Calculations of the Riemann Zeta Function” also contains a great snapshot of what it was like to program the first generation of electronic computers. I’ll start with the widely-quoted introduction to the paper, which I’ve annotated a bit:

“In June 1950 the Manchester University Mark I Electronic Computer was used to do some calculations concerned with the distribution of the zeros of the Riemann zeta-function. It was intended in fact to determine whether there are any zeros not on the critical line in certain particular intervals. The calculations had been planned some time in advance, but had in fact had to be carried out in great haste. If it had not been for the fact that the computer remained in serviceable condition for an unusually long period from 3 p.m. one afternoon to 8 a.m. the following morning it is probably that the calculations would never have been done at all. As it was, the interval 2π632 < t < 2π642 was investigated during that period, and very little more was accomplished.

The calculations were done in an optimistic hope that a zero would be found off the critical line, and the calculations were directed more towards finding such zeros than proving that none existed. The procedure was such that if it had been accurately followed, and if the machine made no errors in the period, then one could be sure that there were no zeros off the critical line in the interval in question. In practice only a few of the results were checked by repeating the calculation, so that the machine might well have made an error.

If more time had been available it was intended to do some more calculations in an altogether different spirit. There is no reason in principle why computation should not be carried through with the rigour usual in mathematical analysis. If definite rules are laid down as to how the computation is to be done one can predict bounds for the errors throughout. [Numerical methods, with or without an automatic computer, should be carefully thought out.] When the computations are done by hand there are serious practical difficulties about this. The computer [he is now talking about a human – later he talks about an “automatic computer”] will probably have his own ideas as to how certain steps should be done. When certain steps may be omitted without serious loss of accuracy he will wish to do so. Furthermore he will probably not see the point of the ‘rigorous’ computation and will probably say “if you want more certainty about the accuracy why not just take more figures?’ an argument difficult to counter. However, if the calculations are being done by an automatic computer one can feel sure that this kind of indiscipline does not occur. Even with the automatic computer this rigour can be rather tiresome to achieve, but in connexion with such a subject as the analytical theory of numbers, where rigour is the essence, it seems worth while. Unfortunately, although the details were all worked out, practically nothing was done on these lines. The interval 1414 < t < 1608 was investigated and checked, but unfortunately at this point the machine broke down and no further work was done. Furthermore this interval was subsequently found to have been run with a wrong error value, and the most that can consequently be asserted with certainty is that the zeros lie on the critical line up to t = 1540, Titchmarsh having investigated as far as 1468.” [Buzzkilling bugs introduced by humans were just a common then as they are now!]

Later on, in the section entitled “The Computations,” Turing briefly describes the “Essentials of the Manchester Computer”:

“It is not intended to give any detailed account of the Manchester Computer here, but a few facts must be mentioned if the strategy of the computation is to be understood. The storage of the machine is of two kinds, known as ‘electronic’ and ‘magnetic’ storage. The electronic storage consisted of four ‘pages’ each of thirty-two lines of forty binary digits. The magnetic storage consisted of a certain number of tracks each of two pages of similar capacity. Only about eight of these tracks were available for the zeta-funtion calculations. It was possible at any time to transfer one or both pages of a track to the electronic storage by an appropriate instruction. [A strategy that remains common today for dealing with slow memory.] This operation takes about 60 ms. (milliseconds). Transfers to the magnetic store from the electronic were also possible, but were in fact only used for preparatory loading of the magetic store. The course of the calculations is controlled by instructions each of twenty binary digits. These are normally magnetically stored, but must be transferred to the electronic store before they can be obeyed. In the initial state of the machine (with the magnetic store loaded) the electronic store is filled with zeros. A zero instruction, however, has a definite meaning, and in fact results in a transfer of instructions to the electronic store, thus initiating the calculation. Most instructions, such as transfer of ‘lines’ of forty digits, take 1.8 ms., but transfers to or from the magnetic store take longer, as has been mentioned, and multiplications take a time depening on the number of digits 1 in the multiplier, ranging from 3.6 ms. for a power of two to 39 ms. for 240 – 1.

The results of the calculations are punched out on teleprint tape. This is a slow process in comparison with the calculations, taking about 150 ms. per character. The content of a tape may afterwards automatically be printed out with a typewriter if desired. The significance of what is printed out is determined by the ‘programmer’. [A word so new that it still needs quotes around it!] In the present case the output consisted mainly of numbers in the scale of 32 using the code

0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
/ E @ A : S I U ¼ D R  J  N  F  C  K  T  Z  L  W  H  Y  P  Q  O  B  G  ?  M  X  V  £

and using the most significant digit on the right. [Yes, you read that correctly. You are required to read your numbers not only in base 32, but also backwards.] More conventionally the scale of 10 can be used, but this would require the storage of a conversion routine, and the writer was entirely content to see the results in the scale of 32, with which he is sufficiently familiar.

And what would these results look like? Here is an eminently readable “typical entry”:

ZETAFASTG/F@Q¼B£YNK@:ZSZ"XVMX///SA/////¼0TNR@O//

“This entry has to be divided into sequences of eight characters. In this case they are:

  1. ZETAFAST. This occurs at the beginning of each entry. Its purpose is mainly to identify the document as referring to this zeta-function routine.
  2. G/F@Q¼B£. This is a number useful in checking results and called the ‘cumulant’. It appears in the scale of 32, with the most significant digit on the right. This is the standard method of representing numbers on documents connected with the Manchester Computer (a decimal method can also be used if desired).
  3. YNK@:ZSZ. This is also in the scale of 32 and gives the residue of 240κ1(τ) modulo 240. Since Z is the symbol for 17 it will be seen that κ1(τ) is near to ½ mod 1.
  4. “XVMX///. This gives the value of 217τ; in this case τ is about 239.24.
  5. SA/////¼. This was always included in the record due to a minor difficulty in the programming. It did not seem worth while to take the trouble to eliminate it. [Some things never change.]
  6. OTNR@O//. This is the value of 230Z(τ) modulo 240. In this case Z(τ) is about 0.75.”

Finally, here is Turing’s table of what was in memory when this program was run:

Magnetic store
  Logarithms routine (for κ)  1 page
  Table of logarithms and reciprocal square roots  4 pages
  Routine for calculating the terms n ^ 1/2 cos 2π (τ log n – κ) and table of cosines  2 pages
  Remainder of routine for calculating the function Z(τ)  2 pages
  Input routine  2 pages
  Output routine  2 pages
Electronic store, as occupied during the greater part of the time
  Instructions and cosines  2 pages
  Logarithms and reciprocal square roots  1 page
  Miscellaneous data and working space  1 page