Return to my Mathematics pages
Go to my home page
Note: If your WWW browser cannot display special symbols, like ² or 2, then click here for the alternative Finite Difference page.
© Copyright 1999, Jim Loy
Let's say that you have some unknown function of x, y=f(x), which gives these values:
x=0, y=5
x=1, y=0
x=2, y=1
x=3, y=20
x=4, y=69
x=5, y=160
x=6, y=305
And you would like to know which function fits those values. One possibility is an n-degree polynomial: y=ax6+bx5+cx4+dx3+ex2+fx+g, for example. You could actually plug the above x and y values into this equation. Then you would have seven linear equations (like 1=64a+32b+16c+8d+4e+2f+g) with seven unknowns. And there are a few fairly easy ways to solve them, to get a, b, c...
A valuable short-cut is called the Finite Difference method. We take the numbers in the table, and find their differences (between consecutive elements), then we find the differences between the differences, etc:
x y diff1 diff2 diff3 diff4
0 5
-5
1 0 6
1 12
2 1 18 0
19 12
3 20 30 0
49 12
4 69 42 0
91 12
5 160 54
145
6 305
It can be shown that for an n-degree polynomial, the nth difference is constant (and the (n+1)th difference is 0). So our function is probably a 3rd degree polynomial. If we had more data, we may find that this is not a 3rd degree polynomial. But for this data, 3rd degree is a perfect fit. We now have 4 equations in 4 unknowns, which simplifies our task.
I suppose I should find the 3rd degree polynomial (y=ax3+bx2+cx+d) that fits the above data. There are numerous methods. I will just add and subtract multiples of equations:
5=0a+0b+0c+d
0=1a+1b+1c+d
1=8a+4b+2c+d
20=27a+9b+3c+d
That is all we need, because we have four unknowns. From the first equation, we see that d=5. So, we now have three equations in three unknowns:
-5=1a+1b+1c
-4=8a+4b+2c
15=27a+9b+3c
We can subtract twice the first equation from the second, and three times the first equation from the third, to get rid of the c's, and get two equations in two unknowns. Then we can simplify them by dividing the first equation by 2 and the second by 6:
3=3a+b
5=4a+b
Then we can subtract the first equation from the second, to get rid of the b's, and find the value of a (2). Substituting 2 for a in either equation gives us b (-3). Going back to an earlier equation, we can substitute 2 for a and -3 for b, and we get -4 for c. And we already knew that d was 5. So the equation is y=2x3-3x2-4x+5.
If this method produces no constant difference, we may need more data. But, it is even more likely that the function that we are looking for is not a polynomial. Functions involving 2x or x! may provide other clues. Here is the finite difference table for y=2x:
x y diff1 diff2 diff3 diff4 diff5 diff6
0 1
1
1 2 1
2 1
2 4 2 1
4 2 1
3 8 4 2 1
8 4 2
4 16 8 4
16 8
5 32 16
32
6 64
It should be obvious that this never can reach a constant difference. And the pattern is suggestive of some power function.