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 = ---------------------------
2 a
```

```
# | 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!

The Analytical Engine was to have a startling resemblance to modern computers. Charles Babbage managed to divine a number of features for his Engine that today we take for granted when programming. Here’s a list of some of the cards that could be used in programming the Engine, some of which should be startlingly familiar to a programmer:

• Number cards — assign a constant to a location in the Store (memory)
• Variable cards — move data between the Mill (processor) and Store; these came in three flavors:
• Transfer a number from the Store to the Mill
• Transfer a number from the Store to the Mill, but zero that location in the Store afterwards
• Transfer the contents of the last operation in the Mill to a location in the Store
• Operation cards — perform the specified operation on the specified data. The base operations were addition, subtraction, multiplication, and division, although extraction of roots was to be standard, and previously-programmed algorithms could be reused if the cards were handy
• Decimal expansion cards — recast a number with a different precision (each of the 1000 numbers in the Store could have up to 50 digits)
• Stepping up/stepping down cards — multiply or divide a number by 10, which is pretty easy in base 10
• Combinatorial cards — repeat steps:
• Move backwards by several cards
• Move forwards by several cards
• Always perform the specified movement
• Perform the specified movement if (essentially) the program has not reached a specified number of cycles
• Advancement cards — perform one set of instructions if a statement is true, and another if it is false
• Inclusion request cards — specify a previously-programmed algorithm that should be imported into the program and used later
• Bell card — ring a bell on the Engine in order to to alert the operator
• Halt card — halt execution of the program. Used in conjunction with the advancement cards, this could be programmed to occur if (for example) one tried to divide by zero
• Trace cards — begin or end tracing, which is to say, have the operator crank through the program manually, noting the results of each individual calculation
• Comment cards — these are skipped during program execution, but can contain, of course, comments on the algorithm
• Plotter control cards — these controlled the built-in grapher for the Engine:
• Change X-coordinate of the pen to the result currently in the Mill
• Change Y-coordinate of the pen to the result currently in the Mill
• Raise the pen
• Lower the pen
• Printer control cards — these controlled the built-in printer for the Engine:
• Print the contents of the Mill
• Print a comment
• Print a number to a specified precision
• Print a number with a specified formatting (e.g., periods and commas)

As you can plainly see, Babbage was a visionary. The above list contains loops, shifts, program tracing, commenting, include statements, system alerts, and other programming tools we see in modern development programs. Many of the cards in the list above were not the direct inspiration for their modern-day equivalents — we are left to wonder what the world would be like if Babbage had actually completed his Engine 150 years ago.

Source: http://www.fourmilab.ch/