Difference Engine

Posted by Jake Good
on May 10, 08

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...

  1. Given a function: p(x) = 2x2 + 3x + 6
  2. And values of x: 1, 2, 3, 4, 5
  3. We can calculate the p(x): 11, 20, 33, 50, 71
  4. Then calculating the differences we get the first set to be: 9 (20 - 11), 13 (33 - 20), 17 (50 - 33), 21 (71 - 50)
  5. We can then calculate the second difference: 4 (14 - 9), 4 (17 - 14), 4 (21 - 17)... note the 2nd difference is common
  6. Since we have a common value, we can now use simple addition to generate tables for p(x) very quickly.

Here's how...

  1. 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.

  2. We can then take A and add it to the previous result: p(x = 5) = 71... to get the value 96, value B.

  3. 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:

  1. p(x = 6) = 2x2 + 3x + 6

  2. p(x = 6) = 2(6)2 + 3(6) + 6

  3. p(x = 6) = 72 +18 + 6

  4. 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!

Comments

Leave a response

  1. fshivoneMay 12 08 @ 05:45PM
    Jake -- I love the machine, did you say your calculations are simple? For you maybe.
Comment