Dataescher Newton Curve Fitter

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.

Your values Forward differences Reverse prediction Click any black number to edit it. Decimals and fractions like 3/4 work too.

Difference table

Walk through the algorithm

Reading the table

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.

Fitted curve

Black dots are your values, hollow red dots are the reverse-pass predictions, and the blue line is the fitted polynomial.

Best fit curve

The row index counts from zero at the top, so f(0) is the first hexagon of the n column.

Newton form
Simplified polynomial (degree )

Where the terms come from

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

How the table is built

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.

  1. Forward pass. Working left to right, each cell is the value below-left minus the value above-left, so the Δn column holds first differences, Δ2n holds differences of those, and so on.
  2. Reverse pass. To extend the sequence, assume the highest order difference stays constant and copy it down one row. Then work back to the left, adding the cell to the right to the cell above, until a brand new value appears in the n column. That value is what the fitted polynomial predicts next.
  3. Read off the formula. The top cell of each column is a coefficient of the Newton form f(n) = Δ0n + Δ1n · n + Δ2n · n(n − 1)/2! + Δ3n · n(n − 1)(n − 2)/3! + …, where the argument n is the row index. That expands into an ordinary polynomial.

All arithmetic here is exact. Values are kept as rational numbers, so coefficients such as 56 stay exact instead of drifting into floating point round-off, and the curve is guaranteed to pass through every value you entered.

Linking to a table

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

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.