Starting from:
$30

$27

MATH 340 LAB 5 Assignment

MATH 340 
LAB 5 Assignment

Lagrange’s Interpolant Polynomial:
For a set of n+1 data points (x0, y0),(x1, y1), . . . , (xn, yn) we want to approximate
a given function f(x) by a polynomial interpolating those data, given by
Pn(x) = y0L0(x) + y1L1(x) + . . . + ynLn(x)
where each Li(x) is a Lagrange’s polynomial defined as
Li(x) = (x − x0)(x − x1)· · ·(x − xi−1)(x − xi+1)· · ·(x − xn)
(xi − x0)(xi − x1)· · ·(xi − xi−1)(xi − xi+1)· · ·(xi − xn)
, i = 0, 1, . . . , n .
Problem 1)
Implement Lagrange’s interpolation to find the interpolating polynomial Pn(x).
For each of the following problems, plot the function f(x) and the resulting Lagrange polynomial Pn(x) you found. Furthermore, to visualize if you are correctly
interpolating the data points (xi
, yi) given, plot them on the same figure using a
marker, not a continuous line style (for instance you can make circles by putting
the option ’o’ in the plot command). Note that to find your polynomial and to
plot it, you need an appropriate domain. You can use a very fine grid of points
with endpoints [x0, xn], unless specified differently in the problem.
1.1) Problem 45 in the Homework. Calculate the error Err = |f(x) − Pn(x)|, at
the points x = 1, and x = 5. How does this error compare with the one predicted
by the theory? (You will learn more about the error theory in class).
1.2) Problem 49 in the Homework. Find Pn(0) and show that the result you obtained is the one expected.
1.3) Problem 68 in the Old Exams file. Compare the estimate given by the theo1
retical error, with the actual error you get Err = |f(x) − Pn(x)| at x = 0.2.
Always remember to answer all questions, to significantly discuss your results,
comment your code, and put labels, title and legend to your figures to obtain full
credit for your work.
2

More products