Polynomial interpolation
This functionality does not run in MATLAB.
interpolate(xList
,yList
,X
, <F
>) interpolate(nodes
,values
,ind
, <F
>)
interpolate
computes an interpolating polynomial
through data over a rectangular grid.
The call interpolate(xList, yList, X)
with xList
= [x_{1}, …, x_{n}]
and yList
= [y_{1}, …, y_{n}]
returns
the polynomial of degree less than n in
the variable X
which interpolates the points (x_{1}, y_{1}),
…, (x_{n}, y_{n}).
This call with a 1dimensional
grid xList
is equivalent to the corresponding ‘multidimensional'
call interpolate([xList], array(1..n, [yList]), [X])
.
For ddimensional interpolation, assume that indeterminates ind = [X_{1}, …, X_{d}] are specified. The interpolating polynomial P = poly(…, [X_{1}, …, X_{d}], F) satisfies
for all points
in
the grid. P is
the polynomial of minimal degree satisfying the interpolation conditions,
i.e., degree
(P, X_{i})
< n_{i}.
If only interpolating values at concrete numerical points X_{1} = v_{1},
…, X_{d} = v_{d} are
required, we recommend not to compute P with
symbolic indeterminates ind
= [X_{1},
…, X_{d}] and
then evaluate P(v_{1},
…, v_{d}).
It is faster to compute this value directly by interpolate
with ind
= [v_{1},
…, v_{d}].
Cf. examples Example 1 and Example 3.
We consider a 1dimensional interpolation problem. To each node x_{i}, a value y_{i} is associated. The interpolation polynomial P with P(x_{i}) = y_{i} is:
xList := [1, 2, 3]: yList := [y1, y2, y3]: P := interpolate(xList, yList, X)
The evaluation of P at the point is given by:
evalp(P, X = 5/2)
This value can also be computed directly without the symbolic polynomial:
interpolate(xList, yList, 5/2)
delete xList, yList, P:
We demonstrate multidimensional interpolation. Consider data over the following 2dimensional 2 ×3 grid:
XList := [1, 2]: YList := [1, 2, 3]: values := array(1..2, 1..3, [[1, 2, 3], [3, 2, 1]]): P := interpolate([XList, YList], values, [X, Y])
Next, interpolation over a 3dimensional 2 ×3×2 grid is demonstrated:
L1 := [1, 2]: L2 := [1, 2, 3]: L3 := [1, 2]: values := array(1..2, 1..3, 1..2, [[[1, 4], [1, 2], [3, 3]], [[1, 4], [1, 3], [4, 0]]]): interpolate([L1, L2, L3], values, [X, Y, Z])
delete XList, values, P, L1, L2, L3:
We interpolate data over a 2dimensional grid:
n1 := 4: L1 := [i $ i = 1..n1]: n2 := 5: L2 := [i $ i = 1..n2]: f := (X, Y) > 1/(1 + X^2 + Y^2): values := array(1..n1, 1..n2, [[f(L1[i], L2[j]) $ j=1..n2] $ i=1..n1]):
First, we compute the symbolic polynomial:
P := interpolate([L1, L2], values, [X, Y])
Fixing the value Y = 2.5, this yields a polynomial in X.
evalp(P, Y = 2.5)
It can also be computed directly by using an evaluation point for the indeterminate Y:
interpolate([L1, L2], values, [X, 2.5])
If all indeterminates are replaced by evaluation points, the corresponding interpolation value is returned:
interpolate([L1, L2], values, [1.2, 2.5])
delete n1, n2, f, values, P:
We demonstrate interpolation over a special coefficient field. Consider the following data over a 2dimensional 2 ×3 grid:
XList := [3, 4]: YList := [1, 2, 3]: values := array(1..2, 1..3, [[0, 1, 2], [3, 2, 1]]):
With the following call, these data are converted to integers modulo 7. Arithmetic over this field is used:
F := Dom::IntegerMod(7): P := interpolate([XList, YList], values, [X, Y], F)
Evaluation of P at grid points reproduces the associated values converted to the field:
evalp(P, X = XList[2], Y = YList[3]) = F(values[2, 3])
delete XList, YList, values, F, P:

The nodes: a list 

The values: a list 

An indeterminate or an arithmetical expression. An indeterminate
is either an identifier (of domain type 

A list [L_{1}, …, L_{d}] of d lists L_{i} defining a ddimensional rectangular grid . The lists L_{i} may have different lengths n_{i} = L_{i}. The elements of each L_{i} must be distinct. 

A ddimensional , 

A list of d indeterminates
or arithmetical expressions. Indeterminates are either identifiers
(of domain type 

Either The returned polynomial is of type For the default field For 
Interpolating polynomial P of
domain type DOM_POLY
in
the indeterminates specified by ind
over the coefficient
field F
is returned. The elements in ind
that
are not indeterminates but arithmetical expressions are not used as
indeterminates in P,
but enter its coefficients: the polynomial is "evaluated"
at these points. If no element of ind
is an indeterminate,
the value of the polynomial at the point specified by ind
is
returned. This is an element of the field F
or
an arithmetical expression if F
= Expr
.
For a ddimensional rectangular grid
specified by the lists
with associated values
,
the interpolating polynomial in the indeterminates X_{1}, …, X_{d} is given by
with the Lagrange polynomials
associated with the kth node of the jth coordinate.