Due: Friday, January 27 by 10:30AM
Charles Babbage's Difference Engine computed the values of a polynomial f(x) of up to degree 7 using the method of finite differences. Write a computer program that asks the user for the initial settings for each of the 8 columns of the machine (one for the function value and 7 for the difference functions of order 1 through 7, as discussed in class. These input values should represent the values of the respective functions evaluated at x = 0.
The program should then ask the user how many times the machine should be cranked. One "crank" represents a complete cycle of the machine that advances the machine from f(x) to f(x+1). The results of the columns should be displayed VERTICALLY, as they would have appeared on the real machine. (Display them horizontally for a little less credit.)
For example, if f(x) = x2 + 3x + 4, then Δ(x) = 2x + 4 and Δ2(x) = 2. So the initial settings of the columns would be:
4 4 2 0 0 0 0 0If the machine is cranked three times, then the results in the columns would be (shown to 4 digits):
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 2 1 0 0 0 0 0 0 2 0 2 0 0 0 0 0(The first column shows 22, the second column shows 10, and the third column shows 2.)
The entry of the initial values of the 8 columns does not need to be all on one line, as shown above. They can be entered one at a time, starting with f(0), then Δf(0), then Δ2f(0), etc. But the output should be as shown. (Horizontal output for columns will receive slightly less credit.)
You may add additional features to this program to simulate the machine more directly. Examples might include:
Embellishments that show significant skill will be awarded additional points and may be presented in class.
You are allowed to use Python, Java, or C for your code. You should include a README.txt file that gives instructions on how to compile, run, and interact with your program. Ask us if you want to use a different language.
Zip up all files that are required to run your program and hand in to Autolab (on andrew). You do not need to hand in any library files that are standard to the language you are using. If you're not sure, ask your teaching assistant. Your submission should be a zip file ending in the suffix .zip .
Assignments will be graded out of 100 points. For maximum credit (100 points), we expect that your program will contain one significant embellishment beyond the basic requirements of the assignment. Showing a picture of Charles Babbage is not considered a significant embellishment. Assignments that meet the basic requirements will receive 90 points.
Programs may be handed in up to 24 hours late with a 20% penalty.