Divided Differences

Using the standard notation, a divided-difference table is shown in symbolic form in Table 7.4.

Table 7.4: Divided-difference table in symbolic form.
$x_i$ $f_i$ $f[x_i,x_{i+1}]$ $f[x_i,x_{i+1},x_{i+2}]$ $f[x_i,x_{i+1},x_{i+2},x_{i+3}]$
$x_0$ $f_0$ $f[x_0,x_1]$ $f[x_0,x_1,x_2]$ $f[x_0,x_1,x_2,x_3]$
$x_1$ $f_1$ $f[x_1,x_2]$ $f[x_1,x_2,x_3]$ $f[x_1,x_2,x_3,x_4]$
$x_2$ $f_2$ $f[x_2,x_3]$ $f[x_2,x_3,x_4]$  
$x_3$ $f_3$ $f[x_3,x_4]$    



Table 7.5: Divided-difference table in numerical values.
$x_i$ $f_i$ $f[x_i,x_{i+1}]$ $f[x_i,x_{i+1},x_{i+2}]$ $f[x_i,\ldots,x_{i+3}]$ $f[x_i,\ldots,x_{i+4}]$
3.2 22.0 8.400 2.856 -0.528 0.256
2.7 17.8 2.118 2.012 0.0865  
1.0 14.2 6.342 2.263    
4.8 38.3 16.750      
5.6 51.7        


\begin{indisplay}
\begin{array}{ll}
x=x_0: & P_0(x_0)=a_0 \\
x=x_1: & P_1(x_1)=...
...)a_2+\ldots\\
& +(x_n-x_0)\ldots(x_n-x_{n-1})a_n\\
\end{array}\end{indisplay}

Example py-file: Constructs a table of divided-difference coefficients. Diagonal entries are coefficients of the polynomial. mydivDiffTable_interpolation.py

Image 14-1

$\displaystyle P_3(x)=f[x_0]+(x-x_0)f[x_0,x_1]+(x-x_0)(x-x_1)f[x_0,x_1,x_2]
$

$\displaystyle +(x-x_0)(x-x_1)(x-x_2)f[x_0,x_1,x_2,x_3]
$

    1 import numpy as np
    2 D=np.array([[ -0.736],  [2.480], [3.000], [2.000]])
    3 print(np.transpose(D))
    4 # [[-0.736  2.48   3.     2.   ]]
    5 import sympy as sym
    6 x = sym.Symbol('x')
    7 P3=D[0]+(x-0.3)*D[1]+(x-0.3)*(x-1)*D[2]+(x-0.3)*(x-1)*(x-0.7)*D[3]
    8 print(P3)
    9 # [2.48*x + 2.0*(x - 1)*(x - 0.7)*(x - 0.3) + 3.0*(x - 1)*(x - 0.3) - 1.48]
   10 print(sym.expand(2.48*x + 2.0*(x - 1)*(x - 0.7)*(x - 0.3) + 3.0*(x - 1)*(x - 0.3) - 1.48))
   11 # 2.0*x**3 - 1.0*x**2 + 1.0*x - 1.0
which is same with the starting polynomial.