3 Homework Set No. 3: Problem 1
3 Homework Set No. 3: Problem 1
3
Problem 1.
Problem 2.
Show that f (x) − p(x) = 21 f ′′ (ξ)(x − a)(x − b) for some ξ in the interval (a, b), where p
is a linear polynomial that interpolates f at a and b.
Hint: Use an error estimate from polynomial interpolation.
Problem 3.
ax3 + x2 + cx
−1 ≤ x ≤ 0
S(x) = .
bx3 + x2 + dx 0≤x≤1
Problem 4.
a). Let L(x) be the linear spline that interpolates the data. Describe what L(x)
consists of and what conditions it has to satisfy. Find L(x), and compute the
value for L(1.8).
1
b). Let C(x) be the natural cubic spline that interpolates the data. Describe what
C(x) consists of and what conditions it has to satisfy. Find C(x), and compute
the value for C(1.8).
Do not do this problem in Matlab. Part (b) can be time consuming, therefore you could
use Matlab to solve the linear system here.
Write a matlab function that computes the first order spline for a given data set. You
might need to take a look at the file cspline_eval.m for problem 7 to start with. Call
your matlab function lspline, define it in the file lspline.m as:
function ls=lspline(t,y,x)
% lspline computes the linear spline
% Inputs:
% t: vector, contains the knots
% y: vector, contains the interpolating values at knots
% x: vector, contains points where the lspline shoule be
% computed
% Output:
% ls: vector, contains the values of lspline at points x
Use your matlab function on the data set given in problem 5, plot the linear spline for
the interval [1.2, 2.2].
What to hand in: Hand in the matlab file lspline.m, and the plot of your linear
spline.
The goal of this home work is to draw the mountain Everest with the help of spline.
We have a photo, probably rather poor quality, of the mountain, which is given below.
We are aware that the mountain tops are not very clear in that photo, so please use
your fantasy. Select your knots, measure these points to generate your data set. Use the
functions cspline and cspline_eval , which are available from the course web site.
Read these two functions carefully, try to understand them before using them.
What you need to hand in: A Matlab script that reads in your data set, compute
the spline functions, and draw the mountain. Also the plot of your mountain Everest.
2
Figure 1: Natural cubic spline, for Mount Everest.