Graphics Programs Reference
In-Depth Information
All the P 's in the table are estimates of the root resulting fromdifferentorders
of interpolation involving different datapoints.For example, P 1 [ y 1 ,
y 2 ] is the root
obtained from linear interpolationbased on the first two points, and P 2 [ y 2 ,
y 4 ] is
the result from quadratic interpolationusing the last three points. The root obtained
from cubic interpolation overall four datapoints is x
y 3 ,
=
P 3 [ y 1 ,
y 2 ,
y 3 ,
y 4 ]
=
3
.
8317.
EXAMPLE 3.4
The datapoints in the table lieon the plot of f ( x )
=
4
.
8 cos
π
x
/
20. Interpolate this
databyNewton's methodat x
=
0
,
0
.
5
,
1
.
0
,...,
8
.
0 and compare the results with the
“exact”values givenby y
=
f ( x ).
x
0
.
15
2
.
30
3
.
15
4
.
85
6
.
25
7
.
95
y
4
.
79867
4
.
49013
4
.
2243
3
.
47313
2
.
66674
1
.
51909
Solution
% Example 3.4 (Newton's interpolation)
xData = [0.15; 2.3; 3.15; 4.85; 6.25; 7.95];
yData = [4.79867; 4.49013; 4.22430; 3.47313;...
2.66674; 1.51909];
a = newtonCoeff(xData,yData);
'
x
yInterp
yExact'
forx=0:0.5:8
y = newtonPoly(a,xData,x);
yExact = 4.8*cos(pi*x/20);
fprintf('%10.5f',x,y,yExact)
fprintf('\n')
end
The results are:
ans =
x
yInterp
yExact
0.00000
4.80003
4.80000
0.50000
4.78518
4.78520
1.00000
4.74088
4.74090
1.50000
4.66736
4.66738
2.00000
4.56507
4.56507
2.50000
4.43462
4.43462
3.00000
4.27683
4.27683
3.50000
4.09267
4.09267
Search WWH ::




Custom Search