Charles Babbage's Analytical Engine (AE) was the precursor to the modern computer; in fact, its design was similar to many early computers. Though Babbage never built the AE, he left detailed instructions as to its functionality. Unlike the Difference Engine (DE), which was a calculator for all purposes... the AE is a programmable machine. Babbage worked on the AE from 1834-1871. In theory, this is how the AE would have worked:
- There would be columns with a series of wheels with the numbers 0-9 engraved on them. Each column would be a number, either a constant, a variable, or just a storage location. The number of columns would dictate just how big of a number the AE could handle. There would also be a column for denoting the sign.
- The programmability of the AE comes from punch cards (Jacquard's loom had just such a mechanism, which Babbage adapted into his design). The contents of two columns would be combined somehow... just how they were combined would be controlled by the punch card. There would be 3 types of cards: (1) number - to allocate constants, (2) operations - basic mathematical operations, and (3) variable - used to determine which column to send results to.
- Later on, Babbage also proposed a method for repeating instructions. For example, if you wanted to keep multiplying the contents of two columns, the AE would keep doing it until it encountered a new instruction.
For example, if you wanted to program the AE to solve the quadratic equation, you would do something as follows (nX means column X):
-b + root( b2 - 4ac )
x = ---------------------------
# | Operation | Operands | Storage | Explanation
1 | Constant | N/A | n0 | Store a into n0
2 | Constant | N/A | n1 | Store b into n1
3 | Constant | N/A | n2 | Store c into n2
4 | Constant | N/A | n3 | Store 2 in n3
5 | Constant | N/A | n4 | Store 4 in n4
6 | * | n1, n1 | n5 | Store b2 in n5
7 | * | n0, n4 | n6 | Store 4a in n6
8 | * | n2, n6 | n6 | Store 4ac in n6 (notice overwriting)
9 | - | n5, n6 | n7 | Store b2-4ac in n7
10| Sqr root | n7 | n7 | Store the square root of n7 in n7
11| - | n7, n1 | n7 | Store -b plus the result of n7 in n7*
12| * | n0, n3 | n8 | Store 2a in n8
13| / | n7, n8 | n9 | Store the numerator divided by the denominator in n9
* So you get one of the two possible solutions in n9. To get the other, you have to go back to step 11 and take the negative of n7 before you go through with that step.
Note: I programmed rather inconsistently here. One, I loaded the constants 2 and 4 into storage locations instead of just specifying them directly. Two, I overwrote some storage locations - in effect recycling them - but I didn't take this to the extreme for clarity's sake. If I had wanted to use the least amount of memory possible, I would have done that. Three, although this seems like a very complicated program, it should be clear that by modifying instructions 1 through 3, it is possible to create a program that solves nearly any quadratic equation. The power thus lies in the reusability and speed of the machine's program.
Programmers will notice that the above "code" is very similar to many lower level languages, such as Assembly. Babbage was, in essence, trying to create a primitive computer that supported low-level programming. It is no surprise that Babbage was not able to build such a machine, because it would have been very complicated in a mechanical form (of course, he hadn't thought of the use of electronics, which was still quite a ways ahead).
I hope there aren't any mistakes in this program! If there are, please /msg me - thanks!