Storytalk Reprint: Sherlock Holmes and the Analytical Engine

Evocative Image of the Sherlock Holmes and the Analytical Engine Story

STAP Editor: Over the years since 1887 when Sherlock Holmes first appeared in publication, there have been many a gnarly case his keen skills in abductive reasoning have solved. But the case of the Analytic Engine in the April 1984 issue of Softalk truly tested the limits of his deductive thinking. Scans of the actual pages (154-57) can be found in the April '84 issue profile.


Some few of you may know that I have uncovered some previous works of Mycroft Holmes relating hitherto unknown adventures of his illustrious brother, the great detective. Dr. Watson mentioned Mycroft in the "Bruce-Partington Plans" and the "Greek Interpreter." But several years ago, while studying in England doing research in the War Office, I uncovered, in a dark corner of a storeroom of unclassified documents, a packet of papers with the inscription "Sherlock's" on it and the initials "MH" scrawled in a broad, careless hand.

Only my closest friends have had the chance to share such adventures as "The Malevolent Leprechaun," "The Neopolitan Plate," and "The Secret Agent"—three of Sherlock Holmes's cases that Mycroft related in those papers. This adventure I share with my readers because it throws light on what may be a missing link in the development of the computer as we know it today.

But let me not get ahead of the tale as Mycroft wrote it circa 1896.
—B. B. Wolff, Jr.

War clouds were looming across Europe, even if the general public was not aware of it. With the demise of Bismarck, Kaiser Wilhelm II was pursuing an aggressive policy in Europe and Africa. Espionage was being honed to a fine edge by both us and the Germans. I knew this, dear reader, from my position with Her Majesty's government. It was one of my tasks to ferret through all the countless reports of our spies, endless reams of diplomatic correspondence, and, where we could decipher them, intercepted coded messages of the German government or its allies and agents. Then I would ascribe some meaning to events and present my findings to the Prime Minister.

But even though Dr. Watson alluded to my coordinative and synthetic prowess, I was finding the amount of data coming in to be too much even for me. I do admit to being human, though I don't ever remember admitting thus to Sherlock, who probably wouldn't have believed me at any rate. So I found myself staring at a large stack of documents my clerk had just laid in front of me—right next to yesterday's stack, which was, in turn, piled next to that of the day before. While I was told that work in the diplomatic corps could be hazardous, as I found out in "The Malevolent Leprechaun," I never thought of death by drowning in a sea of paper as one of those perils.

Yet here I faced mounting wave on wave. While I turned over what had gone through my brain of three days past, I heard a knock on my door. To most people a knock on the door is a familiar event, but for me it was a rare circumstance. I received the deluge of documents from my clerk each morning and afternoon, and I dispatched my synthesis of the data in a special pouch the first thing each morning. Every Monday I met with the Prime Minister and his cabinet to answer questions and to elaborate on what I suspected or predicted in my synthesis. This routine was only rarely disturbed, and in those cases there was an extraordinary crisis brewing.

I squirmed in my chair and called out, "Yes. Come in, will you." In the frame of the door stood my long-time colleague, Sir Geoffrey Wren. He was a man of considerable size and ruddy complexion. He had been with Her Majesty's forces in Afghanistan twenty years ago, was wounded twice, and was awarded the Victoria Cross, presented by none other than the Queen herself. He now headed up the intelligence section of the War Office with the rank of general.

None of us wore uniforms as such, though Wren's tweed was his customary suit. He took his pipe from between his lips and, shutting the door, spoke.

"Mycroft, pardon my intrusion on your reverie, but I really am damn well concerned about your last report. Unless I read you altogether wrong, you implied in yesterday's report that Germany was brewing up a volatile kettle in Africa to throw fuel on the Boer crisis. Now I know you are not getting all the data you need to put this matter together more solidly. Not so?"

"Yes, Geoffrey, I need a great deal more analysis to put all the pieces together.

"And what about the code, the blasted German code. We have all the pieces but we can't make out the puzzle. We know they funnel their plans from Nairobi, up the Nile to Khartoum, and then to Cairo across the Mediterranean to the Balkans. We can get at them anywhere in Africa with our contacts in Nairobi or Cairo. But the blasted code has us stumped.

"I need one thing to help me get at this; not even a thousand more hands will help; I need another synthesizer—another brain like mine to fit together all these diverse bits and put them into a meaningful picture."

"Where on Earth, much less on this isle, this England, shall we find such a one? Where is another Mycroft Holmes?" asked Sir Geoffrey.
"Elementary, my dear Wren. My brother may be of some help."

"Sherlock Holmes! I respect your brother's ability as a criminologist, but what does he know of international politics?"

"The only difference between my mind and Sherlock's is the end of our endeavors, not the means or method. He puts together from diverse evidence a synthesis, the science of deduction, Geoffrey, in the same way I deduce the next move of Germany from the particles of evidence I see in these documents."

I waved my hand across the sea of papers, perhaps like Moses to part the waters. Sir Geoffrey Wren put his pipe back between his teeth and sucked it futilely.
"I think I understand."

"Sherlock gets his data by prowling around with a glass or questioning goose merchants or stalking along dark alleys and in opium dens. My data are handed to me neatly copied by my clerk or clipped from newspapers."

"Even if your brother could help us, how do we know he would be available? And what of the code? What does he know of encryption?"

"The thought of leaving here, of neglecting these," I said, pointing at the Red Sea, "is too enervating, too immobilizing for words, Geoffrey. But I'll send my clerk around to him with my card to find out if he'll be in; he's likely to be in Devon chasing large dogs across the Grimpen moor."

Some hours later my clerk reported back with a handwritten note: "Always in to you, old boy. Be at Baker Street for tea." When I arrived at 221B, Sherlock was sitting at his table, a resplendent tea service set out before him and various sweets prepared no doubt by Mrs. Hudson, who had shown me up and was still standing by the door. "Thank you, Mrs. Hudson, I shall enjoy partaking of your crumpets. If they taste as good as they look I shall be putting on a few more unneeded pounds."
"Oh, Mr. Mycroft, it's always such an event when you come to call. If you want more, just ring."

"Mycroft, how nice to see you. What draws you to Baker Street? More than Mrs. Hudson's biscuits, I'll wager."

"A matter of some moment—a quest, if you will, for a doubling of my brain."

"Please sit here," Sherlock said, brushing off a chair for me as if it had been polluted by one of his experiments. He poured my cup. "This service may be new to you, Mycroft, a gift from the Imam of Ranjier for a service I rendered him last year." He sat across from me and took his cup delicately in his graceful hand and peered at me. "Come, come, Mycroft, pleasantries were never our metier. Out with it. How shall we duplicate your brain?"

"That, my dear brother, is precisely my question of you." I went on to explain my onerous workload and the need not only to speed my comprehension of the volumes of data but to unravel the German code as well.

"So you need a way to sift and winnow the masses of data you have to look at, to catalog it, to compare and relate it, and to infer from that some conclusion or prediction of future events. That is point one, isn't that so, Mycroft?"

"Just so."

"And the second thing you need to do is assist in decryption of code by a reiterative processor that can make many trials and comparisons of code and probable messages or already broken fragments. That is point two, is it not?"

"Just so again, brother."

Sherlock reached for his sock of tobacco and knocked the ashes from his cold pipe, which lay against an empty glass humidor. Filling the pipe absently, his eyes rolling toward the ceiling, he lit the tobacco and puffed smoke in rings toward a spot on the ceiling. I looked up too, hoping to see a sign like Constantine in the heavens. But all that was there was a musty plaster, encrusted with too many of Sherlock's foul concoctions.

His eyes came back down and he smiled as he said, "Have a biscuit, Mycroft; Mrs. Hudson will be sorely disappointed if you leave a crumb."

As I munched on Mrs. Hudson's morsels, I watched Sherlock go to a large cabinet full of papers in seeming disarray. "You see, Mycroft, there is order in all this," he said, waving a sheaf of papers at me. "Here are the Babbage papers."

"Do you mean the late inventor and mathematician?"

"None other, Mycroft. Here, read this tonight. In the meanwhile I'll summarize it. Mr. Babbage invented a machine to do repetitive calculations of complex formulas at astounding speeds."

I turned the papers over and noted they constituted a piece published by the Royal Society and written by Charles Babbage nearly forty years ago.
"The story is he never finished the machine; he called it his Analytical Engine. The problem as I understand it was that he could not get the financing to finish its construction—a highly expensive endeavor involving the hand cutting of many intricate gears and cogs."

"Yes, Sherlock, I remember looking into this for the government a few years ago; but without Babbage to guide the project, we felt it couldn't be done."

"Now here's another for you, Mycroft: A Mr. Hollerith in the States has used sets of punched cards to do their census. He uses them to sort out and count people. Now with a little ingenuity I should think you could catalog and cross-refer your documents using Hollerith's technique. By judicious cross-referencing you'll be able to retrieve connected pieces of information and do it quickly."

"By Jove, Sherlock, I think you've hit upon it. That solves one of my two problems, but what about the German code? Prime Minister Jameson of South Africa maintains the Germans in West Africa and in East Africa are trying to cause further trouble in Transvaal and break the uneasy truce there between us and the Boers. There's nothing the Kaiser would like better than to send us running all over South Africa while he moved up the Nile and 'liberated' the Sudan."

"Yes, I can imagine the skullduggery that's being perpetrated there in the name of diplomacy. But here is where I think our friend Charles Babbage may serve his country posthumously. I think his Analytical Engine was preceded by another machine called the Difference Engine, less flexible than the Analytical Engine but still very fast in computation. We need to get the machine from the British Museum for a while with permission to make a few adjustments. Can you arrange this?"

"We may have to go through Salisbury, but I think it could be arranged. Do you want it delivered here?"

Just then we were interrupted by a knock on the door. "That's Watson, Mycroft. I'm convinced he'll prove to be invaluable in this enterprise; may I take him into our confidence?"

"Sherlock, your judgment is impeccable."

Sherlock let in Watson, who had that merry wink in his eye that said he felt he was in on something or felt a case coming for his old friend. "I knocked because Mrs. Hudson said you had an important visitor, and I didn't want to barge in."

"Nonsense," said Sherlock, "you know you are my good right arm, Watson."

"Ah, Mycroft, how nice to see you again; your comings are too far apart."

I arose from my chair and shook his hand warmly. "Always nice to see you, Doctor."

"Well, I see you have tea, humph."

"Please, Watson, sit down and take tea and listen to a proposition I will put before you to help Mycroft on a problem he faces. We need to use your skillful hands in designing and building some gears and cams to drive an engine."

"What's that? I haven't done that kind of thing for fifteen years."

"It will come back to you, Watson; it will assuredly come back to you. You see, Mycroft, I think the Difference Engine with a few changes can be made to do repetitive tasks needed to break the German code."

"I say, Holmes, is this similar to the code you deciphered in 'The Case of the Dancing Men'?"

"No, no, Watson, I'm afraid this one is devilishly more clever. That one was a simple substitution code using one figure to mean one letter. This one, I would guess, is a multiple offset substitution code."

Watson gaped at this.

"Say we substitute the number 1 for the letter A, 2 for B, and so forth till 26 for Z. Now say we change the offset so that 7 is for A, and 8 for B and so on with 6 for Z. Or we can use letter substitutes, letting, say, F stand for A, G for B and so on until E stands for Z. A coder-decoder can be made very simply by putting two concentric circles, one inside the other, each with the twenty-six letters of the alphabet around it. Now we can set the offset by turning one circle so that the A in the inner circle lines up with a letter in the outer circle. So we could line up A with F. Now we can easily code a message by using the outer ring as the clear message and the corresponding letter on the inner ring as the cipher."

"But, Holmes, that's really nothing more than the problem you said was so easy in the 'Dancing Men.' "

"Quite so and very observant, Watson, but if I am correct and the Germans are using such a code, they will vary the offset on each letter according to a preset pattern using a number sequence from 0 to 25. The key to the code is the number sequence, and finding it and testing the results is the job for the Difference Engine."
"Sherlock, what makes you think the Germans would use such a code? There are many others even harder to decipher."

"Two reasons, Mycroft. One, the logistics, the length of the German communication. They must keep it simple so they can easily change it. And two, they are dealing with a variety of agents, many of whom don't even know the German alphabet, much less the German language. Now, Mycroft, can you get us that machine?"
"I'll leave at once to arrange for delivery tomorrow."

The delivery men came the next day and set the ponderous object upon the floor. I watched my brother's eyes take in the machine and pour over it gear by gear. His disheveled look told me he had spent most of the night reading Babbage's accounts of how the machine worked.

Watson asked, "You said they needed a sequence of numbers; how does that work?"

"In two ways; they can either have a book with a long list of numbers, or they can work with a seed number that is acted upon in some way to produce a second number that becomes the seed for the next number. Once you know the seed and the formula, you can derive the offset numbers from the sequence. Depending on how many letters are in the alphabet being used, a number greater than the total number of letters would be converted to a number less than the sequence by dividing the number by the sequence and taking pi, which I'm sure you remember is an endless number that begins 3.141592653589793238462. There are two ways to approach this if this is a key. We could break the number into pairs and compute modulus 26. First the pairs would be 31 41 59 26 53 58 97 93 23 84 62. The remainders would be 5, 16, 7, 0, 1, 6, 19, 15, 23, 6, 10. Now say we wanted to encode the phrase HELLO WATSON. Using our wheel, we would get MUSLP CTIPUX."

"We have our work cut out for us, Holmes, if we mean to break such a complicated code."

I will not detail the endless hours that went into the next three weeks while Sherlock figured and Watson cut gears. The machine cranked away and spewed out a seemingly endless series of numbers. Sherlock, with his unusual ability to concentrate on a problem with complete intensity and abandonment for long periods of time, was remarkable. I've never seen it in another man—not Gladstone, nor Chamberlain, nor Balfour, none.

In the third week, one dreary afternoon with the fog thick around the ministry, I was again disturbed by a knock at my door. This time it was Sherlock, with a grin that assured me the cat was in the bag.

"Here it is, Mycroft; I thought I'd deliver it myself. We found the key; they used a simple center squaring technique, with the Kaiser's birthday as the initial seed. I'd keep the engine running, though, because they may change the key in the future, but I'll show some of your people how to run the blasted thing so I can get down to Surrey for a rest. By the by, Mycroft, can you arrange to let me see the Analytical Engine? Even if it wasn't finished, I think it has some promise in criminology. I have an idea that you could produce the same results more efficiently using electrical relays—like the telephone, what? It has some future to it, I'll wager."

I shook my head. "Yes, it may indeed."

"Can't you visualize a dossier on every criminal in England on Hollerith's cards fed into the Engine and compared to a recent crime? Or picture an analysis of crimes across the city to find a pattern, perhaps even to predict where a crime might occur?"

"Yes, Sherlock, I can see a world of uses for such a machine—a thousand different outcomes for it to compute."

"Yes, Mycroft, a computer, indeed."