Kits
QRP Labs |
Other Radio Topics
Frequency Counters
Electronics
Guest Project Gallery
The University of Mandelbrot |
Written by Hans Summers | |||||
Friday, 31 December 2010 10:47 | |||||
Well I was not long turned 19 years old when I arrived at Imperial College, University of London to study a physics degree. In the first year, three afternoons per week were to be spent in the laboratory on practical experiments. One of the lab subjects was computing, and by good fortune I was in the lab group which did computing first. The 1'st year physics laboratory computer was a VAX. Connected to this were about 40 or 50 terminals. A handful were real WYSE terminals, the rest were ex-BBC computers (popular 1980's UK home/educational computer); they had had their ROM replaced such that they behaved like terminals. The computer course aimed to teach us Fortran 77 and we were advised to forget any previous bad habits, such as the BASIC we might have learnt from our 1980's home computers (ZX Spectrum, BBC, Commodore 64 etc). This was supposed to make it easier to learn a "real" programming language like Fortran. I suspected this advice would be unuseful, and was not proved wrong. Why Fortran? Apparently most scientific programming took place in Fortran because of the large scientific libraries available in Fortran. I did not particularly like Fortran though the VAX was the fastest computer I had ever used. I have in any case always felt that a good programmer could make sense of ANY programming language. In the course of my professional life I have used several, finding it easier each time to learn a new one. Some things might be easier or more difficult in different languages but ultimately any program comes down to logic, and if you are good with logic you'll be able to write good programs in almost any language once you've learnt the particular syntax and rules. Of some concern was the disk space allocation to each student, of just 500 blocks. One VAX "block" is actually 512 bytes, so 500 blocks corresponds to about 250K of disk space. This was plenty for the simple Fortran programs but not so much space for storing the output files of Mandelbrot sets. But then again we weren't supposed to be creating Mandelbrot sets. The VAX operating system, VMS, I found very nice. I later worked on a legacy VAX application in my first job, where I learnt a lot more VMS. It is easy to use, type "Help" and you can be sure of finding a clear explanation of anything you want to know about the VMS commands. VMS is not case sensitive like UNIX, and you can abbreviate commands as short as you like so long as there is no ambiguity. For example, for a directory listing you can type "directory", "direc", or "dir". But not "di" as other commands also start "di" and VMS obviously can't resolve the ambiguity. By reading the Help files I learnt a lot of interesting VAX commands. Things like "broadcast", which allowed you to cause a message to appear on another terminal once you knew their port number. Or "phone" where you could chat to one or more other students using the keyboard. Not that there was much utility in messaging someone who sat only a few feet from you but it was fun. Naturally a lot of friends learnt the use of these commands from my example, curious about how the messages on their screens were caused. Messages appearing on the recipient's screen in the middle of their program editing caused some disruption since the messages overwrote the program listing or anything else they might be doing on the computer. So there was also quite a high amusement factor. By using the /reply qualifier they were forced to reply to you or the message request would keep pinging up on their screen for ever. I discovered you could also message the VAX operator console. Which is how I first met Mrs M, who was somewhat in charge of the running of the computer section of the lab, and very little amused by my irritating use of /reply interrupting her work. She shot out of the lab office door like a bull, shouting for SUMMERS_HJA to identify themselves. It wasn't a good start. Later, Mrs M made some modifications to the permissioning to restrict that useage of some of the more damaging commands. For example, they stopped /all on the "broadcast" command, which sent a message to EVERY terminal screen. I don't think they'd ever had students on that system who had known about all those commands. I have always said, ignorance is the best security. Unfortunately, we weren't ignorant so they had to resort to more blunt security devices. The computing course consisted of a number of exercises, each teaching us various aspects of Fortran programming in a Physics setting. After some preliminary tutorials we started solving differential equations (see graph above right. Click here for a larger version, 600 x 454, 9K), some matrix manipulation (for solving simulataneous equations), and finally modelling of a chaotic double-pendulum system. Two forms of output were available: a line printer (dot matrix) which could print program listings. This could only print text output, like program listings or results. The other output device was an X-Y pen plotter. Our programs were linked to a graphics library for graphing results, this produced a nice graph image on the screen which could be sent to the X-Y plotter where it was drawn onto an A4-sized piece of paper. The paper is placed in the plotter and drawing takes place by a small pen which is moved all over the paper by motors in the vertical and horizontal directions (relative to the paper). The pen is raised or lowered to create lines as it is moved. It can draw lines and curves without lifting the pen, but numbers and the graph tick marks are drawn in small strokes, lifting the pen between strokes. This creates quite a noise as the pen is repeatedly raised and lowered. Quite an amusing machine. Very soon, an alternative use for the X-Y plotter suggested itself to my mind. Mandelbrot sets! The difficulty was that the graphics library did not allow me to draw points, it was just a scientific graphing program. That however was merely a temporary obstacle. Soon I discovered that the drawing of the axes, title and value labels could be supressed. I could draw very many short lines, so short they would look like a point. I could draw one for each coordinate of the Mandelbrot set, drawing a line or not depending on whether the number of iterations at each coordinate was an odd or even number. This did not quite work, because the graphics program consumed too many resources storing the start and end point of each of these tiny lines. The graph had to be stored on disk before it could be printed. Remember I said, we only had 500 blocks (250K) of disk space each. And a lot of it was already used up by my real coursework. The solution was simple. The Mandelbrot program would scan across the page from left to right in lines, as usual. When the colour of a point changed from white to black, the coordinate of that point would be stored. Subsequent points were then evaluated and when the colour next turned back to white (or the right edge of the picture was reached), a line would be drawn connecting that coordinate to the previous stored one. This resulted in far far fewer lines being drawn and the output file could fit inside the available disk space. The picture to the right is a close up of my Mandelbrot plot: this illustrates the principle but in reality the lines are a lot more even. The process of scanning them in has caused some distortion. When I had this nice Mandelbrot set drawn on the green terminal screen, the next thing to do was print it on the X-Y plotter. I suspected that the huge detail of the Mandelbrot set would take somewhat longer to draw than the usual graphs associated with the computer course. Therefore I would probably not make any friends amongst fellow students by plotting the set during the official course hours. So I returned the following morning when the lab was quiet, logged in (SUMMERS_HJA) and issued the command to send my Mandelbrot file to the X-Y plotter. A tremendous racket ensued, twice as loud as the ordinary plotter noise from the course graphs, as my Mandelbrot set contained so many short lines which had to be drawn by lifting and setting down the pen in quick succession. After watching for a few moments to satisfy myself that all was going according to plan, I calculated a prediction of how long plotting would take, based on the time taken to plot the first few lines and knowledge of the total number of lines. I left the lab and went about my ordinary business. Perhaps a lecture to attend or some such. I returned approximately one and three quarter hours later when the estimated time had elapsed, and sure enough the plot was close to completion. However my return was not uneventful. Standing (perhaps "hopping" would be a better description) next to the plotter in full tornado mode was a furious Mrs M. This SUMMERS_HJA chracter was becoming troblesome. Evidently earlier that morning she had replaced the worn out pen of the plotter with a brand new one. Well, I had indeed noticed that the lines of my Mandelbrot plot were looking very neat and more clear than usual, so it did make some sense. She was highly perterbed by my Mandelbrot set which was busily destroying her brand new pen by it's repeated raising and slamming down of the pen on the paper at so much higher a rate than was ordinarily supposed to happen. To this day I still wonder quite why Mrs M allowed my Mandelbrot set plot to complete. With complete control over everything that happened in the VAX she would have been able to terminate it before it was able to do too much damage to her pristine new pen. Perhaps she wanted to catch me in the act. Maybe she wondered what a Mandelbrot set was (she's a Physicist, after all). Or is there a small chance that somewhere deep inside she could see the funny side? It was many months before normal diplomatic relations were resumed. I was requested in no uncertain terms to desist from such activities in future. An order which was not obeyed: I produced several more Mandelbrot sets. Below is a series of three, from the entire set on the left to two successive magnifications, of the same areas as illustrated in the centre pages of James Gleick's book "Chaos". You can see that the quality of the line drawing is never as clear or as black as it was on my first set, with the brand new pen. Click on the pictures or links under them for larger views. My VAX Mandelbrot hack is one of my favourite Mandelbrot set adventures, I still treasure the X-Y plotter outputs. |
|||||
Last Updated on Friday, 31 December 2010 11:23 |