Polynomial interpolation

Description

To get a better interpolation for f(x)f(x), we can add a curvature to the function with an nthn^{th} degree polynomial when we have n+1n + 1 points:

fn(x)=b0+b1(xx0)++bn(xx0)(xx1)(xxn1)f_n(x) = b_0 + b_1(x - x_0) + \cdots + b_n(x - x_0)(x - x_1)\cdots(x - x_{n - 1})

To get the coefficients b0b_0, b1b_1, …, bnb_n:

b0=f(x0)b1=f[x1,x0]b2=f[x2,x1,x0]bn=f[xn,xn1,,x1,x0]\begin{aligned} b_0 = & f(x_0) \\ b_1 = & f[x_1, x_0] \\ b_2 = & f[x_2, x_1, x_0] \\ \vdots \\ b_n = & f[x_n, x_{n - 1}, \cdots, x_1, x_0] \\ \end{aligned}

The functions with brackets are finite divided differences where:

f[xi,xj]=f(xi)f(xj)xixjf[xi,xj,xr]=f[xi,xj]f[xj,xr]xixrf[xn,xn1,,x1,x0]=f[xn,xn1,,x1]f[xn1,xn2,,x1]xnx0\begin{aligned} f[x_i, x_j] = & \dfrac{f(x_i) - f(x_j)}{x_i - x_j} \\ f[x_i, x_j, x_r] = & \dfrac{f[x_i, x_j] - f[x_j, x_r]}{x_i - x_r} \\ \vdots \\ f[x_n, x_{n - 1}, \cdots, x_1, x_0] = & \dfrac{f[x_n, x_{n - 1}, \cdots, x_1] - f[x_{n - 1}, x_{n - 2}, \cdots, x_1]}{x_n - x_0} \end{aligned}

If we have an additional value f(xn+1)f(x_{n + 1}), we can evaluate the error with the following equation:

Rn=f[xn+1,xn,xn1,,x0](xx0)(xx1)(xxn)R_n = f[x_{n + 1}, x_n, x_{n - 1}, \cdots, x_0](x - x_0)(x - x_1)\cdots(x - x_n)

Calculator