Unformatted text preview: ch data point, then we are conﬁdent that we have the correct answer. The
Interpolating
Polynomial Enter the x  and y values of the data points (−3, 0), (−2, −3), (0, 3), and (2, −15) in the
vectors x and y.
>> x=[3 2 0 2];
>> y=[0 3 3 15];
The minimum and maximum x values of the set of data points are −3 and 2, respectively. Let’s
sketch the polynomial p(x) = −x 3 − 3x 2 + x + 3 over the interval [−4, 3]. This will ensure
that each of the given data points is visible in our ﬁnal plot. The following commands should
produce a graph similar to that in Figure 4.
>>
>>
>>
>> p=[1 3 1 3];
xp=linspace(4,3); % 100 equally spaced points from 4 to 3
yp=polyval(p,xp);
plot(x,y,’ro’,xp,yp,’’) Matlab’s plot command is an extremely ﬂexible tool. In this case, note that we are creating two
plots with one command. In general, the command plot(x1,y1,s1,x2,y2,s2,...,xN,yN,sN)
will draw N plots: the plot of y1 versus x1, the plot of y2 versus x2, and ﬁnally, the plot of yN
versus xN. Line styles, markers, and colors are deﬁned for each plot in the strings 4 s1, s2,. . . ,sN. title page
contents
previous page
next page
back
print doc
close 4 In Matlab, ’ro’ is an example of a string. Note that strings are delimited by single apostrophes. exit 20 The 10 Interpolating 0 Polynomial −10
−20
−30
−40
−50
−4 −2 0 2 title page 4 Figure 4 The interpolating polynomial must pass through each data point. contents
previous page The Vandermonde Matrix
Suppose that you wish to ﬁnd a fourth degree interpolating polynomial that passes through the
points (x1 , y1 ), (x2 , y2 ), (x3 , y3 ), (x4 , y4 ), and (x5 , y5 ). If you substitute each of these points
in the polynomial y = ax 4 + bx 3 + cx 2 + dx + e, you will arrive at the following system of linear
equations.
3
4
2
ax1 + bx1 + cx1 + dx1 + e = y1 3
4
2
ax4 + bx4 + cx4 + dx4 + e = y4
3
4
2
ax5 + bx5 + cx5 + dx5 + e = y5 back
print doc 3
4
2
ax2 + bx2 + cx2 + dx2 + e = y2
3...
View
Full Document
 Summer '12
 Gaussian Elimination, Row echelon form, Interpolating Polynomial, print doc

Click to edit the document details