October 2007 Simulation of Meccano Differential Analyzers Keith Smillie Meccano n. Trademark. A construction set of miniature metal or plastic parts from which mechanical models can be made. The Collins Paperback English Dictionary. Introduction The first differential analyzer was built in 1931 by Vannevar Bush at the Massachusetts Institute of Technology. This work soon came to the attention of Douglas Hartree of the University of Manchester who, assisted by his research student Arthur Porter, built a model consisting mostly of Meccano parts to judge its suitability for calculations arising in atomic physics. With the successful completion of the model, funds were obtained for the construction of a full-scale machine which was built commercially. During World War II this machine and several other similar ones including one at the University of Cambridge were used for military purposes. With the development of electronic digital computers in the late 1940s and in the 1950s, these machines were no longer used. However at present there is considerable interest in the construction of Meccano models of differential analyzers and their use for educational purposes. The present paper describes a simulation, written in the J programming language, of a four-integrator Meccano model and gives a few examples of its use. The pioneering Manchester work is described in Porter (2003). Two papers, Robinson (2005a) and Robinson (2005b) give, respectively, a history of the Meccano models and a description of the contemporary construction of one such machine. A brief description of the J language and a comparison with conventional programming languages is given in Smillie (2000). Integrators The one or more integrators in a differential analyzer, usually designated by the Roman letters I, II, III, ... , are identical in design and differ only in their interconnections with other components of the machine. Each integrator consists of a small vertical wheel which turns on its horizontal axis as it rolls on the surface of a horizontal disk which rotates on a vertical axis. The displacement of the wheel from the centre of the disk varies as the disk rotates and is proportional to the value of the dependent variable. The rotation of the disk gives the change in the independent variable. Suppose that the disk rotates through a small angle ∆x and that the wheel is at a radial distance y from the centre of the disk. Therefore the wheel is turned an amount ∆z = (y∆x)/a, where a is the radius of the wheel. Thus after a given period of operation the total rotation of the wheel is proportional to ∫ydx. Since the wheel rests lightly on the disk so that it may slide freely along a radius as the value of the dependent variable changes, its torque must be amplified before its motion may be transmitted to another part of the analyzer. As this simulation models only the logic of the differential analyzer, the design and construction of torque amplifiers may be ignored although they are an important feature in the Meccano models. Let us assume now that the disk rotates in discrete steps of size ∆x and that the rotation of the disk begins when x has the value x0. Also assume that the initial radial displacement of the wheel on the disk is y0 and that subsequent displacements are y1, y2, ... .. Then the successive rotations of the wheel are (∆x)y1/a, (∆x)y2/a, ... . Therefore, the total rotation of the wheel after n steps is proportional to the sum (∆x)y0 + (∆x)y1 + (∆x)y2 + ∙∙∙ + (∆x)yn . As ∆x becomes smaller, this sum will correspond more closely to the rotations of the physical disk and wheel, and thus become a better approximation to the value of the desired integral. In the simulator the interconnections of the integrators are defined by dyadic functions, one for each integrator, and named I, II, III and IV. The variables representing the rotating shafts, one for the independent variable and one for each integrator, are named x, z1, z2, z3 and z4 so that they may be referred to simply and unambiguously in the integrator definitions. As an example we shall see in the next section that the one integrator required for the solution of the first-order differential equation discussed there is defined by the expression z1=: x I z1 which is equivalent to the corresponding schematic diagram for the interconnections of the differential analyzer. Each execution of this function corresponds to a term in the discrete model discussed in the last paragraph. The values of x and z1 are stored in a two-column table TABLE1 for that integrator with the values of x in the first column and the corresponding values of z1 in the second. The Windows form given at the end of the paper shows the format used for the input of the integrator definitions and their initial settings and for the display of the results of a simulation. 2 Solving a first-order equation We shall discuss the simulator by showing its use to solve the simple first-order differential equation dy/dx = y which has a solution y = exp(x) where exp is the exponential function. We shall assume that the integration is from x = 0 to x = 3 so that the final value of dependent variable y is 20.0855. The differential analyzer connections for this problem are shown in the schematic diagram on the left. The upper horizontal line represents the shaft driven by the analyzer motor (not shown) while the second horizontal line represents the shaft giving the solution which is driven by the connecting shafts and gears. The vertical lines show the interconnections between the integrator and the two shafts. The figure on the right shows the simulator after its use for the solution of this problem. The radiobutton for the number of integrators is set at 1, its default value. The integrator is defined by the expression z1=: x I z1 as given in the preceding section. The initial values are given in the first three boxes of initial values. The graph is shown in the large box on the right and the final value of the function is 19.7885. (Changing the x increment to 0.001, for example, gives a more accurate final value of 20.0755.) The solution is stored in the twocolumn table TABLE1 which has 301 rows of which the first five and last five are as follows: 0.00 1.0000 0.01 1.0100 0.02 1.0201 0.03 1.0303 0.04 1.0406 ..... 2.96 19.0163 2.97 19.2065 2.98 19.3986 2.99 19.5925 3.00 19.7885 3 Second-order equations In this section we shall give two examples of the use of the simulator to solve second-order ordinary differential equations, the first for simple harmonic motion and the second for damped oscillations. At the same time we shall illustrate some additional features of the simulator. The first example for simple harmonic motion requires the solution of the equation d2y/dx2 = -y with the initial conditions y(0) = 0 and dy/dx(0) = 1. (We might note that the solution apart from an arbitrary constant is y = sin x.) The schematic for setting up the differential analyzer is shown on the left from which we may derive the expressions z1=: x I –z2 and z2=: x II z1 for the integrators. In the Windows form given below we note that we have plotted the solution against the independent variable x by selecting radiobutton x in the first row and radiobutton 2 in the second row in the box below the graph. This may be done either initially and then clicking the OK button, or after the simulation and then clicking the Plot button. (The default selection of the radiobuttons is x in the first row and 1 in the second which in this example will give the graph of the cosine funcion.) Also by selecting either radiobuttons 1 and 2 in the first and second rows, or radiobuttons 2 and 1, we obtain a circular plot. In the second example we wish to solve the equation d2y/dt2 + 2dy/dt + 50y = 0 4 for damped oscillations with initial conditions y(0) = -0.1 and dy/dt(0) = 0. We shall omit the schematic for the integrators and give only the J expressions and initial values required by the simulator. The two integrators I and II are defined by the expressions z1=: x I z2 and z2=: x II -(50*z1)+2*z2 , and the initial conditions are 5 for the maximum value of the independent variable, 0.01 for the increment, and _0.1 and 0 for the initial values of the dependent variable and the first derivative. Instead of displaying the Windows form showing the graphical solution of the equation, we shall assume that the simulation has been performed and that the user has switched to the J execution window. The two-column variable TABLE gives the solution with the values of the independent variable in the first column and the values of the dependent variable in the second. The graph may be displayed by the expression Plot TABLE giving in this example the graph shown on the right. We might note that the table corresponding to the currently displayed graph, whether resulting from an initial simulation initiated by the OK button or from the subsequent selection of radiobuttons and use of the Plot button is given in the variable TABLE. Furthermore the tabular values may be copied into the clipboard by the expression Copy TABLE where they may be used, for example, in a spreadsheet. Definite integrals The simulator may be used to obtain the value of a definite integral ∫f(x)dx for a given function f(x) and a specified upper limit of integration. In this section we shall give two examples which make use of the first- and second-order equations solved in the first two examples given earlier. In the first example consider the probability density function for the standard normal distribution given by (1/√2π)exp(-x2/2) for x in the range -∞ to +∞. The exponential term may be computed by defining the first integrator as z1=: x I –x*z1 which follows from the simulator definition in the first example. The integration which will give the 5 cumulative density function, tabulated in most statistical texts, is given by the second integrator defined as z2=: x II 0.39894*z1 where the constant multiplier 0.39894 is the value of the reciprocal of √2π. With initial values for the simulator of 2, 0.001, 1 and 0.5, a value of 0.9772 is obtained for the definite integral. In the second example we shall find the value of ∫sin x dx integrated from x = 0 to x = π which has the value 2. The sine function may be generated by the expressions z1=: x I –z2 and z2=: x II z1 given in the second example, and the integration performed by the third integrator defined by the expression z3=: x III z2 . With initial values 3.14, 0.001 1, and 0, the value of the definite integral is given by the final value of the third integrator. Acknowledgements I wish to thank Arthur Porter for stimulating my interest in Meccano differential analyzers and for his continuing interest in this work, and Tim Robinson for his very helpful comments on a draft of this paper. References Bromley, Allan G., 1990. “Analog computing devices.” In Computing Before Computers, William Aspray (ed.), Iowa State University Press, Ames, Iowa. Gullberg, Jan, 1997. Mathematics: From the Birth of Numbers. W. W. Norton & Company, New York. Lawrence, Bonita, 2007. Personal communication. Porter, Arthur, 2003. “Building the Manchester differential analyzers: A personal reflection.” Annals of the History of Computing, vol. 25, no. 2, pp. 86 – 92. Robinson, Tim, 2005a. “The Meccano set computers.” IEEE Control Systems Magazine, vol. 25, no. 3, pp. 74 – 83. Robinson, Tim, 2005b. Tim Robinson’s Differential Analyzer. http://www.meccano.us /differential_analyzers/robinson_da/index.html. Smillie, Keith, 2000. A Lecture on Array Languages. http://www.cs.ualberta.ca/~smillie/Jpage/Jpage.html. 6 −−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−−− Keith Smillie is Professor Emeritus of Computing Science at the University of Alberta, Edmonton, Alberta T6G 2E8. His email address is smillie@cs.ualberta.ca. Windows form for simulator 7