Enter a handful of values and this tool builds the forward difference table used by Newton's method of finite differences, then hands back the polynomial that passes exactly through every one of your values. The table is drawn as a tower of hexagons: your values occupy the leftmost n column, and each column to the right holds the difference of the two cells to its left.
3/4
work too.
Each green cell is the difference of the two cells to its left, so the hexagon between 9 and 19 holds 10. The red cells reverse that arithmetic: the highest order difference is repeated, then each cell to the left is the sum of the cell above it and the cell to its right, ending with a brand new n value.
Black dots are your values, hollow red dots are the reverse-pass predictions, and the blue line is the fitted polynomial.
The row index counts from zero at the top, so f(0) is the first hexagon of the n column.
Only the top cell of each column feeds the formula. Term k is that value divided by k!, multiplied by a falling factorial.
| k | Top of column | Term |
|---|
Newton's method of finite differences fits a polynomial to a set of equally spaced samples. Given n values it produces a polynomial of degree at most n − 1, which is why the number of columns always matches the number of values you supply: the last column holds a single difference, and there is nothing left to differentiate.
All arithmetic here is exact. Values are kept as rational numbers, so coefficients such as 5⁄6 stay exact instead of drifting into floating point round-off, and the curve is guaranteed to pass through every value you entered.
Every control can be set from the query string, so a particular table can be bookmarked, shared or linked from a document. The address bar keeps itself up to date as you work, and Copy link puts the current link on the clipboard.
/apps/newton-curve-fit/?v=4,9,19,39&rows=1
v — the values, separated by commas, as in v=4,9,19,39. Decimals and fractions
such as 1/2 are accepted, and this also sets how many values there are.
rows — how many red predicted rows to generate, from 0 to 6.
Defaults to 1.
cnt — how many values, from 3 to 10. Only needed if it should differ
from the length of v: a longer list is trimmed, a shorter one is padded with predicted values.
preset — a named sequence instead of explicit values: example,
squares, cubes, triangular, fibonacci, powers
or primes.
x1, x2, x3… — one parameter per value, if that suits the
caller better than a list. ?cnt=4&x1=4&x2=9&x3=19&x4=39 is the same table as the
example above.
Anything that cannot be read as a number stays in its cell exactly as it was passed and is flagged in red, with the table treating it as zero, so a bad link is easy to spot instead of quietly changing the answer.