Finite Differences
Licensed under Creative Commons: other posts

algorithm

Graphing contour lines of polynomials.

If you take a polynomial, such as 3x2 - 2x + 3, and evaluated it at points spaced evenly, such as 0, 2, 4, 6, and 8, you get a sequence of numbers, such as 3, 11, 43, 99, 179. If you then subtract pairs of numbers in that sequence you get another sequence, such as 8, 32, 56, 80. Do it again (24, 24, 24) and again (0, 0) and eventually you get only zeros.

The first number in each of those sequences (3, 8, 24, 0, 0, …) are the “‍finite differences‍” of the polynomial. You can use them to rapidly evaluate the polynomial at evenly-spaced by adding later numbers to earlier ones. So from (3, 8, 24) we go to (3+8=11, 8+24=32, 24) then (11+32=43, 32+24=56, 24) then (99, 80, 24), then (179, 104, 24), then (283, 128, 24), etc.

Finite differences are a fast and effective way to draw graphs of polynomials, including contours lines of 2D polynomials.

 Polynomial of x and y: Pixel step-size: Contours: