Cubic Polynomial Generator, Interpolator and Plotter

This script generates a cubic polynomial from four points. The x coordinates x1 through x4 must all be different. The script will also interpolate (or even extrapolate!) to give a y value for any x coordinate, x5. Just for the sake of example, the page automatically loads width the results from the four points (-1,-1), (2,2), (3,1) and (4,2) with an interpolation to x=2.5.

x1
y1
x2
y2
x3
y3
x4
y4
x5

y=2.8+1.8x
-1.7x2+0.3x3

y(x5)=1.3625

or

y=2.8+1.8*x
-1.7*x**2+0.3*x**3