The Charles Babbage difference engine... used to calculate polynomial functions... by hand cranking and setting initial values, with each column having a decimal value... you could do number crunching and generate large tables of calculations (logarithmic and trignometric)...
The math behind a difference engine is pretty simplistic...
- Given a function: p(x) = 2x2 + 3x + 6
- And values of x: 1, 2, 3, 4, 5
- We can calculate the p(x): 11, 20, 33, 50, 71
- Then calculating the differences we get the first set to be: 9 (20 - 11), 13 (33 - 20), 17 (50 - 33), 21 (71 - 50)
- We can then calculate the second difference: 4 (14 - 9), 4 (17 - 14), 4 (21 - 17)... note the 2nd difference is common
- Since we have a common value, we can now use simple addition to generate tables for p(x) very quickly.
Here's how...
Take the 2nd difference, in our case 4 (constant)... and add it into the previous first difference, in our case 25....that gives us the next first difference, value A in the table below.
We can then take A and add it to the previous result: p(x = 5) = 71... to get the value 96, value B.
We have now calculated p(x = 6) = 96 by only doing 2 additions instead of putting the numbers through the function.
Let's double check our work:
p(x = 6) = 2x2 + 3x + 6
p(x = 6) = 2(6)2 + 3(6) + 6
p(x = 6) = 72 +18 + 6
p(x = 6) = 96
w00t!
|
x |
f(x) |
First Difference |
Second Difference |
|---|---|---|---|
|
1 |
11 |
9 |
4 |
|
2 |
20 |
13 |
4 |
|
3 |
33 |
17 |
4 |
|
|
50 |
21 |
4 |
|
5 |
71 |
A |
4 |
|
6 |
B |
|
4 |
So with one very simple calculation, you can quickly generate tables of values for any given polynomial... pretty interesting huh :).
Side note: someone took the time to build one with Legos as well... love it!