Graphics Programs Reference
In-Depth Information
=
Similarly, x
x i + 2 yields
P 2 [ x i ,
x i + 1 ,
=
P 1 [ x i + 1 ,
=
x i + 2 ]
x i + 2 ]
y i + 2
=
Finally, when x
x i + 1 wehave
P 1 [ x i ,
=
P 1 [ x i + 1 ,
=
x i + 1 ]
x i + 2 ]
y i + 1
so that
( x i + 1
x i + 2 ) y i + 1
+
( x i
x i + 1 ) y i + 1
P 2 [ x i ,
x i + 1 ,
=
=
x i + 2 ]
y i + 1
x i
x i + 2
Having established the pattern, wecan nowdeduce
the general recursive
formula:
P k [ x i ,
x i + 1 ,...,
x i + k ]
(3.8)
( x
x i + k ) P k 1 [ x i , x i + 1 ,...,
x i + k 1 ]
+
( x i
x ) P k 1 [ x i + 1 , x i + 2 ,...,
x i + k ]
=
x i + k
Given the valueof x , the computationscan becarried out in the following tabular
format (shown for four datapoints):
x i
k
=
0
k
=
1
k
=
2
k
=
3
x 1
P 0 [ x 1 ]
=
y 1
P 1 [ x 1 ,
x 2 ]
P 2 [ x 1 ,
x 2 ,
x 3 ]
P 3 [ x 1 ,
x 2 ,
x 3 ,
x 4 ]
x 2
P 0 [ x 2 ]
=
y 2
P 1 [ x 2 ,
x 3 ]
P 2 [ x 2 , x 3 ,
x 4 ]
x 3
P 0 [ x 3 ]
=
y 3
P 1 [ x 3 ,
x 4 ]
x 4
P 0 [ x 4 ]
=
y 4
Table 3.2
neville
This algorithmworks with the one-dimensional array y , which initially contains the
y -values of the data (the second column in Table 3.2).Each pass through the for-
loop computes the terms in next column of the table, which overwrite the previous
elements of y .At the end of the procedure, y contains the diagonalterms of the table.
The valueoftheinterpolant(evaluatedat x )that passes through all the datapoints is
y 1 , the first elementof y .
function yInterp = neville(xData,yData,x)
% Neville's polynomial interpolation;
% returns the value of the interpolant at x.
Search WWH ::

Custom Search