Lagrange Interpolation Formula and Reproducing Kernel Bases

Parameters.

maxDegree = 4;

numSamples = maxDegree+1;

Sampling locations / interpolation points.

locs = RandomReal[{-1,1}, numSamples];

Construct kernal matrix / Vandermonde matrix.

V = ConstantArray[ 0, {numSamples,numSamples}];

For[i = 1, i≤numSamples, i++,
For[ j = 0, j ≤ maxDegree, j++,
V[[i,j+1]] = locs[[i]]^j;
]
]

MatrixForm[V]

Construct dual monomial basis functions by inverting the kernel matrix and expanding in monomial reference basis.

SV = Inverse[V];

Dm = ConstantArray[0,numSamples];

For[i=1,i≤numSamples,i++,
For[j=0, j<=maxDegree,j++,
Dm[[i]]+=SV[[j+1,i]]*(x^j);
]
]

MatrixForm[Dm]

Construct Lagranage interpolation functions.

L = ConstantArray[1,numSamples];

For[i=1,i≤numSamples,i++,
For[j=1,j<=numSamples,j++,
If[i≠j,
L[[i]]*=(x-locs[[j]]) /  (locs[[i]]-locs[[j]]); 
]
]
]

MatrixForm[Expand[L]]

Compare dual kernel functions with Lagrange interpolation formula. Note that the maximum error will necessarily be at x = 1 (also compare visually the Dm and L matrix).

maxDiff = 0;

For[i=1, i≤numSamples,i++,
maxDiff = Max[maxDiff,(Dm[[i]]-Expand[L[[i]]]/.x->1)]
]

maxDiff