1 Chapter 4. Interpolation Traditionally, interpolation referred to the process of finding an approxima- tion to a function at some point intermediate to two known function values. In this way, it was possible to estimate, say, the logarithm function of any number, given a table of true logarithm values. What was done was to determine the straight line connecting (or interpolating) the known values and evaluate it at the intermediate value. This evaluation was taken to approximate the desired but unknown function value. Although modern calculators make this method obsolete for the approximation of logarithms, it is still used for functions that are extremely difficult or expensive to compute or for real- time sampled data. In this chapter, we begin with this simple linear interpolation idea and extend it to finding higher order polynomials that interpolate many data points. 4.1 Polynomial Interpolation Recball that through any two points in the plane (x 0 ,y 0 ) and (x 1 ,y 1 ) with x 0 = x 1 there is a unique straight line that passes throught them: (1.1) y − y 1 = y 1 − y 0 x 1 − x 0 (x − x 0 ) This line is said to interpolate the data {(x i ,y i ) | i =0, 1}. A similar but less familiar fact is true for three data points {(x i ,y i ) | i =0, 1, 2}, with x 0 ,x 1 , and x 2 distinct. There is a unique quadratic that passes through, or interpolates, them.
58
Embed
Chapter 4. Interpolation interpolation - Texas A&M …dallen/m609_05c/chapter4.pdf · 1 Chapter 4. Interpolation Traditionally,interpolation referred to the process of finding an
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
1
Chapter 4. Interpolation
Traditionally, interpolation referred to the process of finding an approxima-
tion to a function at some point intermediate to two known function values. In this
way, it was possible to estimate, say, the logarithm function of any number, given
a table of true logarithm values. What was done was to determine the straight line
connecting (or interpolating) the known values and evaluate it at the intermediate
value.
This evaluation was taken to approximate the desired but unknown function value.
Although modern calculators make this method obsolete for the approximation of
logarithms, it is still used for functions that are extremely difficult or expensive to
compute or for real- time sampled data.
In this chapter, we begin with this simple linear interpolation idea and extend
it to finding higher order polynomials that interpolate many data points.
4.1 Polynomial Interpolation
Recball that through any two points in the plane (x0, y0) and (x1, y1) with
x0 �= x1 there is a unique straight line that passes throught them:
(1.1) y − y1 =y1 − y0
x1 − x0(x − x0)
This line is said to interpolate the data {(xi, yi) | i = 0, 1}. A similar but less
familiar fact is true for three data points {(xi, yi) | i = 0, 1, 2}, with x0, x1, and
x2 distinct. There is a unique quadratic that passes through, or interpolates, them.
4.1 Polynomial Interpolation 2
Finding this quadratic and higher order polymomials for more data points is the
subject of this chapter. To begin let us make our notions precise.
Given n+1 data points {(xi, yi) | i = 0, 1, . . . , n} with all xi, i = 0, 1, . . . , n
distinct. In many texts the values xi, i = 0, 1, . . . , n are called the nodes. A
function F (x) that satifies the conditions
(1.2) F (xi) = yi, i = 0, 1, . . . , n
is said to interpolate the data. The process of finding F (x) is called interpolation
and F (x) is called an interpolating function. If F (x) = p(x) is a polynomial then
p(x) is called an interpolating polynomial. For all of the sections of this chap-
ter, except the last, we will be concerned with the determination of interpolating
polynomials. In order that a unique solution exist to the problem of finding inter-
polating polynomials we add in the interpolation problem below the extra condition
that the polynomial be of smallest possible degree.
Interpolation Problem. Given n + 1 data points {(xi, yi) | i = 0, 1, . . . , n}with xi, i = 0, 1, . . . , n distinct. Find a polynomial of smallest possible degree
that interpolates the data; that is, satisfies (1.2).
Five relevant questions immediately arise.
1. Does such an interpolating polynomial exist? And if so,
2. How can it be determined?
3. What is its degree?
4. Is it unique?
5. Suppose the data are sampled. That is, suppose there is an underlying function
f(x) for which yi = f(xi), i = 0, 1, . . . , n. Can we estimate the error of
approximation
f(x) − p(x)
for values of x �= xi, i = 0, 1, . . . , n?
It is easy to see that an interpolating polynomial exists. To show this we proceed by
induction. First of all, in the case n = 0 (one data point), the 0th degree polynomial
4.1 Polynomial Interpolation 3
y = y0 interpolates (x0, y0). For two data points {(xi, yi), i = 0, 1}, the polynomial
of 1st degree (a linear function) was constructed in (1.1) above. Now suppose
that a polynomial pn−1(x) of degree n − 1 interpolates the data {(xi, yi), i =
with the coefficients c0, c1, . . . , cn computed inductively. Importantly, it has degree
at most n. In fact, the degree of pn(x) can be strictly less that n. For example,
observe that the three data points (0,1), (1,2), and (2,3) are interpolated by the
polynomial of degree 1, y = x + 1. (For correct mathematical interpretation, how-
ever, this linear polynomial is also to be considered quadratic.) As we show in the
following example, formulas (1.3) and (1.4) can be used to construct the interpolat-
ing polynomial. But more efficient methods, such as Newton’s Forward Difference
Method, are derived in the next section.
Example 1.1. Use formulas (1.3) and (1.4) to interpolate the data (1,3), (2,5),
and (3,1).
Solution. First we use formula (1.1) to write a formula for the degree 1 that
interpolates (1,3) and (2,5). It is
y − 3 =5 − 32 − 1
(x − 1)
= 2x− 2
y = 2x + 1 (= p1(x)
4.1 Polynomial Interpolation 4
From (1.3) we see that p2(x) has the form
p2(x) = p1(x) + c2(x − 1)(x − 2)
= 2x + 1 + c(x − 1)(x − 2)
Substitute x = 3 into p2(x) above and solve
p2(3) = 2(3) + 1 + c2(3 − 1)(3 − 2) = 1
c2 =−6
(2)(1)= −3
So,p2(x) = 2x + 1 − 3(x − 1)(x − 2)
= 2x + 1 − 3(x2 − 3x + 2)
= −3x2 + 11x − 5
Notice that the degree is 2, one less that the number of data points. There are
many interpolating polynomials that interpolate a given set of data. For example,
the cubic polynomial
p(x) = −3x2 + 11x − 5 + a(x − 1)(x − 2)(x − 3)
interpolates the data of Example 1 for every value of a. But what is true is that there
exists a unique polynomial of degree n that interpolates {(xi, yi), i = 0, 1, . . . , n}.To show this we require the following fact: Every non zero polynomial of degree n
has at most n zeros*. So, if p(x) and q(x) are two polynomials, each of at most
degree n that interpolate the data {(xi, yi), i = 0, 1, . . . , n}, then the difference
r(x) = p(x) − q(x)
is also a polynomial of at most degree n for which r(xi) = 0, i = 0, 1, . . . , n. That
is, r(x) has n + 1 zeros. This cannot happen unless r(x) = 0 for all x. And this
means, of course, that r(x) is the zero polynomial. Let us summarize the discussion
above in the following
Theorem. Given the n + 1 data points {(xi, yi), i = 0, 1, . . . , n}, with
xi, i = 0, 1, . . . , n distinct. Then there exists a unique polynomial p(x) of degree
n that interpolates the data.
* If the nth degree polynomial has a nonzero coefficient multiplying xn, then it
has exactly n zeros. See, Section (2.3).
4.1 Polynomial Interpolation 5
This theorem implies that if the same data {(xi, yi), i = 0, 1, . . . , n} is
interpolated by two polynomials, both of at most degree n, then they must be the
same, even though they may have different forms.
Thus, we have answered the first four of the basic questions above. There is a
polynomial of degree at most n that interpolates the data {(xi, yi), i = 0, 1, . . . , n},and formulas (1.3) and (1.4) can be used to find it. The fifth question will be
answered in Section 4.3.
4.1 Polynomial Interpolation 6
Exercises 4.1
In Problems 1-6 evaluate the given polynomial at the given x-coordinates.
At n − 1 MDs (Multiplications and Divisions) each, this comes to a total of (n −1)(n + 1) MDs. The numerators can be computed more simply. For a given x,
compute the quantity
(x − x0)(x − x1) · · · (x − xn).
This requires n MDs. Then compute
mi = (x − x0)(x − x1) · · · (x − xn)/(x − xi), i = 0, 1, . . . , n
at a cost of one more MD each. Finally, compute pn(x) by the formula
pn(x) = y0m0/d0 + y1n1/d1 + · · ·ynmn/dn.
4.2 Lagrange and Newton Methods 11
This takes 2n+2 MDs. The total MDs is thus (n−1)(n+1)+n+(n+1)+(2n+2) =
n2 + 4n + 2 MDs. Note, however, that once the denominators di, i = 0, 1, . . . , n
and the factors yi/di, i = 0, 1, . . . , n have be calculated and stored, the net number
of MDs for each evaluation of pn(x) is only 3n+2 MDs. As we shall see, this is still
relatively costly.
Algorithm: Lagrange Method
given: n, {(xi, yi), i = 0, 1, . . . , n}x
for i = 0, 1, . . . , n do Check ifif (x = xi) then x = xi, i = 0, 1, . . . , n
p = yi
print pstop
endiffor i = 0, 1, . . . , n do
di = 1 Compute thefor j = 0, 1, . . . , n do denominators
if (i �= j) then of ln,i
di = di ∗ (xi − xj)endif
num = 1 Computefor i = 0, 1, . . . , n do
∏ni=0(x − xi)
num = num ∗ (x − xi)p = 0for i = 0, 1, . . . , n do Evaluate
q = num/(x − xi) pn(x)p = p + yi ∗ q/di
print pstop
Newton’s Divided Difference Methods
We say that a polynomial p(x) is in shifted power form is it can be repre-
for i = n − 1, n − 2, . . . , 0 do Compute pn(x)p = p ∗ (x − xi) + a0i using nested
print p multiplication.stop
To save computer memory it is not necessary to use a matrix to store the wholedivided difference table. In fact, the coefficients of pn(x) can be generated using asingle array. (See problem 26.)
A special formulaWhen the data {(xi, yi), i = 0, 1, . . . , n} is generated from a function f(x),
which means yi = f(xi), i = 0, 1, . . . , n, the coefficients of the Newton forwarddifference formula have a special significance. In particular we have the
Theorem. Let f(x) be an n−times continuously differentiable function on theinterval [a, b]. Suppose that xk, k = 0, 1, . . . , n are n + 1 distinct values in [a, b].Then for each k = 0, 1, . . . , n there is a value ηk in [a, b] for which
(2.16) f [x0, x1, . . . , xk] =f(k)(ηk)
k!
Even more is true: for each fixed i and k, there is a number ξ = ξ(i, k) for which
(2.17) f [xi−k, xi−k+1, . . . , xi] =f(k)(ξ)
k!.
4.2 Lagrange and Newton Methods 23
See problem 27.This theorem, which will be proved in the next section, shows that the Newton
forward difference formula is similar the the Taylor Theorem, though the deriva-tives are evaluated at different points. It also shows that if the function f(x) is apolynomial of degree k, and k < n, then all the coefficients
In problems 1-6 find the Lagrange interpolating polynomial for the given data.
1. (0,1) (2,1) (3,2).
2. (−1, 1) (−2, 0) (2, 3).
3. (−1,−2) (0,−1) (1, 0) (2, 1).
4. (−5,−2) (−3, 1) (1, 7) (2, 1).
5. (4, 1) (2, 3) (−1, 2) (−3,−3).
6. (−1,−1) (6, 2) (4,−1) (1,−1).
In problems 7-12 find the coefficients of the Newton forward difference formula forthe given set of data.
7. (4, 5) (2, 3) (1,−1)
8. (−3, 3) (−1,−9) (4, 31)
9. (−2,−3) (−1,−7) (1,−9) (2, 65)
10. (−6, 1) (−1, 6) (1, 22) (5, 342)
11. (0,−1) (1, 0) (2,−1) (3, 2) (4, 15)
12. (−1, 5) (1, 13) (3, 45) (5, 53) (4, 25)
In problems 13-18 find the coefficients of the Newton backward difference formula.
13. (5,−2) (3, 4) (1, 2)
14. (1,−26) (−2, 1) (−1,−4) (4, 1)
15. (−4, 91) (−2,−3) (2, 1) (4, 3)
16. (−2, 10) (−1, 9) (0,−10) (9,−1)
17. (−1,−9) (0, 24) (1, 7) (2,−6) (8, 0)
18. (−2,−161) (−1,−89) (2,−5) (3,−1) (4, 1)
19. Find the Newton backward difference formula for the data {(kπ, sin kπ), i =0, 1, . . . , 7.
20. Find the Newton forward difference formula for the data {(k, k2), i = 0, 1, . . . , 6.
21. Suppose that p(x) is any polynomial of degree n, and that xi, i = 0, 1, . . . , n
are any n+1 distinct points. Show that the Newton forward difference formulapn(x) that interpolates the data {(xi, p(xi)), i = 0, 1, . . . , n} is equal to p(x)for all x.
4.2 Lagrange and Newton Methods 25
22. Given q(x), a polynomial of degree three. Suppose we interpolate five points{(xi, q(xi), i = 0, 1, . . . , 4}, where all the xis are distinct. Explain why infourth level divided difference f [x0, x1, . . . , x4] = 0.
23. Suppose you are given six points (xi, yi), i = 0, 1, . . . , 5, with all the xis aredistinct, and that there is a quadratic q(x) for which yi = q(xi), i = 0, 1, . . . , 6.How can the divided difference table be used to test this?
24. Suppose the data {(xi, yi), i = 0, 1, . . . , n} is given, and that {(x′i, y
′i), i =
0, 1, . . . , n} represents the exact same set of points. Show that if the divideddifference table is computed for both sets of data, then
f [x0, x1, . . . , xn] = f [x′1, x
′2, . . . , x
′n]
25. Find a formula to numerically compute the derivative of a polynomial pn(x) inNewton’s form. (See, formula (2.6))
26. Find an algorithm to compute the coefficients of the Newton forward differenceformula using only the two original data arrays. (Of course, the original y-datawill be lost.)
27. Verify formula (2.17).
28. Suppose that f(x) is a polynomial of degree k, and that xi, i = 0, 1, . . . , n arearbitrary and distinct. Show that if k < n, then (2.18) holds. (Note that theinterval [a, b] need not be specified because polynomials are defined for all x.
Computer ExercisesI Write a computer program to compute the coefficients of the Newton forward
difference formula for a given arbitrary set of data, and then to evaluate thepolynomial at specified points.
Applications: Use Program I to interpolate the following data.
5. Use Program I to interpolate the data {(2πk/8, sin 2πk/8), k = 0, 1, 2, . . . , 8}and then evaluate pn(x) at π/3. Compute also sin π/3.
4.2 Lagrange and Newton Methods 26
6. Use Program I to interpolate the data {(k, ek), k = 0, 1, 2, . . . , 6} and thenevaluate pn(x) at x = 5.5 and x = 8. Compute also e5.5 and e8.
II. Write a computer program to compute the coefficients of the Newtonbackward difference formula for a given arbitrary set of data, andthen to evaluate the polynomial at specified points. Applications:Use Program II to interpolate the following data.
Data to be inserted
III. Modify Program I to interpolate a given function at a specified set of orderednodes xi, i = 0, 1, . . . , n, and then to evaluate the interpolating polynomialat ten intermediate points to each pair [xi, xi+1]. Determine and print themaximum deviation from the polynomial to the function at these points.Applications: Use Program III to interpolate the given functions.
1. f(x) = 1/(1 + 5x2), xi = cos 2i+112 π, i = 0, 1, . . . , 5.
3. f(x) = |x|, xi = −2 + 2i8 , i = 0, 1, . . . , 8.
4. f(x) = 4x2 + sin 9x, xi = i2
64 , i = 0, 1, . . . , 8.
5. f(x) = 4x2 + sin 9x, xi = i8 , i = 0, 1, . . . , 8.
6. f(x) = 12(e−x − e−2x), xi = i10 , i = 0, 1, . . . , 10.
27
4.3 Error of the Interpolating Polynomial
In this section we suppose the data has the form {(xi, f(xi), i = 0, 1, . . . , n},for some given function f(x) that is n + 1—times continuously differentiable over
some interval. A natural question to ask is this: if pn(x) is the interpolating poly-
nomial for this data, and x is given, what is the difference
(3.1) f(x) − pn(x)
(Recall, Section 4.1, question 5.) We call this the error of approximation at x.
It is natural to expect this error to depend on three factors:
1. The given nodes, xi, i = 0, 1, . . . , n.
2. The selected value of x.
3. Properties of the function f(x).
For example, the further the value x is from the nodes, xi, i = 0, 1, . . . , n, the
greater the error of approximation might be. Or, the more the function oscillates,
the less representative of the function the data {(xi, f(xi), i = 0, 1, . . . , n} will
be and hence the greater the error of approximation. All of this is reflected in the
following theorem
Theorem. Error of Approximation. Assume that f(x) is continuous on the
interval [a, b] and (n + 1)−times continuously differentiable over (a, b), and that
the nodes xi, i = 0, 1, . . . , n are in [a, b]. Let pn(x) be the unique polynomial of
degree ≤ n that interpolates the data {(xi, f(xi), i = 0, 1, . . . , n}. Let x be some
fixed value in [a, b]. Then there is a value ξ in the smallest interval I that contains
the points {x, x0, x1, . . . , xn} for which
(3.2) f(x) − pn(x) =f(n+1)(ξ)(n + 1)!
(x − x0)(x − x1) · · · (x − xn)
where f(n+1)(x) denotes the (n + 1)st derivative of f(x).
4.3 Error of the Interpolating Polynomial 28
To verify this theorem we need a generalized version of Rolle’s theorem. First recall
the basic version of Rolle’s theorem: Suppose that g(x) is continuous on [a, b] and
differentiable on (a, b). If g(a) = g(b) = 0, then there is a value ξ in (a, b) for which
g′(ξ) = 0. This theorem generalizes to the situation when g(x) is zero at several
places in [a, b] as follows:
Theorem. Generalized Rolle’s Theorem. Suppose that g(x) is continuous
on [a, b] and (k + 1)− times continuously differentiable on (a, b). Suppose there
are k + 1 points xi, i = 0, 1, . . . , k in [a, b] at which g(x) is zero. That is,
g(xi) = 0, i = 0, 1, . . . , k. Then there is a number ξ in the smallest interval I that
contains the points xi, i = 0, 1, . . . , k at which
g(k)(ξ) = 0.
The proof of this theorem is really quite simple. First define the function
(3.3)
g(t) = f(t) − pn(t) −[
f(x) − pn(x)(x − x0)(x − x1) · · · (x − xn)
](t − x0)(t − x1) · · · (t − xn).
Note that g(t) is a function of the variable t — the number x is fixed! As a function
of t, we see that for t = xi,
g(xi) = f(xi) − pn(xi) −[
f(x) − pn(x)(x − x0)(x − x1) · · · (x − xn)
](xi − x0)(xi − x1) · · · (xi − xn)
= f(xi) − f(xi) −[
f(x) − pn(x)(x − x0)(x − x1) · · · (x − xn)
]· 0
= 0
for each xi, i = 0, 1, . . . , n. In addition, for t = x,
g(x) = f(x) − pn(x) −[
f(x) − pn(x)(x − x0)(x − x1) · · · (x − xn)
](x − x0)(x − x1) · · · (x − xn)
= f(x) − pn(x) − [f(x) − pn(x)]
= 0
Thus g(t) is zero at the n +2 points {x, x0, x1, . . . , xn}. By generalized Rolle’s theorem there must be a value
ξ in I, the smallest interval containing {x, x0, x1, . . . , xn} so that g(n+1)(ξ) = 0. Now compute the (n + 1)st
derivative of g(t).
dn+1
dtn+1g(t) =
dn+1
dtn+1f(t) − dn+1
dtn+1pn(t) −
[f(x) − pn(x)
(x − x0)(x − x1) · · · (x − xn)
]dn+1
dtn+1[(t − x0)(t − x1) · · · (t − xn)]
4.3 Error of the Interpolating Polynomial 29
Since pn(x) has degree ≤ n, dn+1
dtn+1 pn(t) = 0, for all t. On the other hand, the term
(t − x0)(t − x1) · · · (t − xn) is a polynomial of degree n + 1, which if expanded to
f [x1, x2] − f [x0, x1]f [x2, x3] − f [x1, x2]f [x3, x4] − f [x2, x3]
.
.
.
.
.
.
f [xn−1, xn]− f [xn−2, xn−1]
⎞⎟⎟⎟⎟⎟⎟⎟⎟⎟⎠
Both systems are called tridiagonal because the matrix entries satisfy qij = 0 if
j > i+1 or if i > j +1 and can be solved my the Tridiagonal Algorithm in Chapter
2, Section 4.
Example 5.2. Find the natural cubic spline approximation to f(x) = 3x2−sin 9x
on [0,1], using 5 equally spaced points. Graph the curve and spline.
Solution. We have x0 = 0.0, x1 = .25, x2 = .50, x3 = .75, and x4 = 1.0.
The yi = f(xi), i = 0, 1, . . . , 4. Hence the cubic spline S(x) consists of four
segments, S0(x), S1(x), S2(x), and S3(x). The linear system Qb = g to determine
b = (b1, b2, b3)T is given by⎛⎝ 1.0 .25 0
.25 1.0 .250 .25 1.0
⎞⎠
⎛⎝ b1
b2
b3
⎞⎠ =
⎛⎝ 34.90
−33.7022.09
⎞⎠
Solving this system and using the various formula above we obtain
i xi di = y∗i ci bi ai
0 0.00 0.00 −6.41 0.00 64.801 0.25 −0.59 5.74 48.60 −137.862 0.50 1.73 4.19 −54.80 120.773 0.75 1.24 −0.56 35.78 −47.714 1.00 2.59∗ All numbers have been computed in single precisionarithmetic and rounded to two places.
The graphs are shown in Figure 5.4. The maximum magnitude of the deviation is
about .342. For comparison we have also graphed the natural cubic spline with six
knots.
4.5 Interpolation with Cubic Splines 54
Several reasons for choosing cubic splines standout. First the matching condi-
tions give the spline a completely smooth visual appearence. Although there are
discontinuities in the third derivative at the knots, they are impossible to visu-
ally discern. Second, very little is gained by choosing higher order splines. Indeed
the linear system to be solved for say, quartic splines, is somewhat more compli-
cated. For technical reasons splines of odd order behave better than even order
(say, quadratic) splines. Finally, cubic splines tend not to exhibit wild internodal
fluctuations.
Figure 5.4
Below we give the natural cubic spline algorithm, which is very simple to pro-
gram.
4.5 Interpolation with Cubic Splines 55
Algorithm: Natural Cubic Spline
given: {(xi, yi), i = 0, 1, . . . , n}x
for i = 0, 1, . . . , n − 1 do Compute the�i = xi+1 − xi differences �ix
dfi = (yi+1 − yi)/(xi+1 − xi) f [xi, xi+1]
for i = 1, 2, , . . . , n − 1 doqii = 2(�i−1 + �i) Create the matrixif (i < n − 1) then and the
qi,i+1 = �i vector gqi+1,i = �i
endifgi = 3 ∗ (dfi − dfi−1)
call solve (q, g, b, n − 1) Solve the linear systemfor b1, . . . , bn−1
set b0 = 0, d0 = y0
for i = 1, . . . , n − 1 dodi = yi Determine theai = (bi+1 − bi)/(3 ∗ �i) coefficientsci = dfi = ai ∗ �2
i − bi ∗ �i di, ai, ci
an−1 = −bn−1/(3 ∗ �n−1)cn−1 = dfn−1 − an−1 ∗ �2
n−1 − bn−1 ∗ �n−1
print ai, bi, ci, di, i = 0, 1, . . . , n − 1
if (x < x0 or x > xn) thenprint ’x out of range’stop
In the cubic spline algorithm above, the system can be replace by the tridiagonal
algorithm from Chapter 3.
4.5 Interpolation with Cubic Splines 57
Exercises 4.5
In problems 1-6 determine the linear splines that interpolates the given data.
1. (1, 0) (2,−3) (3,−1) (4, 1)
2. (−2, 0) (0, 10) (1, 13) (2, 10)
3. (0, 0) (2,−6) (3,−6) (5,−6) (7, 2)
4. (−3, 0) (−1, 6) (0, 8) (4, 28) (6, 20)
5. (−2, 0) (−1, 0) (0, 0) (1, 0) (2, 0) (3,−4)
6. (−4, 0) (−2, 0) (−1,−5) (2, 1) (3,−4) (5,−2)
In problems 7-12 determine the coefficients of the natural cubic spline that inter-
polates the given data.
7. (0, 1) (1, 1) (2,−3)
8. (−1,−1) (1, 17) (3, 99)
9. (1, 0) (2,−1) (3,−5) (4,−6)
10. (−2, 2) (0, 12) (2, 46) (4, 56)
11. (0, 0) (2, 0) (4, 0) (6,−16) (8,−96)
12. (−2, 1) (−1,−1) (0,−5) (1,−19) (2,−43)
13. Find the matrix Q when the data is equally spaced. (Assume that xi+1 − xi =
h, i = 0, 1, . . . , n − 1.)
14. Define the linear spline the same as (5.2) replacing (5.2a) with Si(x) = ai(x −xi) + bi over the same range of x and i. Determine the coefficients ai, bi, i =
0, 1, . . . , n − 1.
15. If the data has the form {(xi, f(xi), i = 0, 1, . . . , n}, where f(x) is a cubic,
then is the natural cubic spline the same as f(x) itself? Same question for the
clamped cubic spline.
16. If the data has the form {(xi, f(xi), i = 0, 1, . . . , n}, where f(x) is linear,
then is the natural cubic spline the same as f(x) itself?
17. Explain why the natural cubic spline may not be the best way to approximate
the curve of a projectile shot into the air.
4.5 Interpolation with Cubic Splines 58
Computer Exercises
I Write a program to determine the natural cubic spline to the given the data
{(xi, yi), i = 0, 1, . . . , n} S(x) at a given point x.
Data to be inserted
II Modify the program (I) to determine the natural cubic spline to the given the
data
{(xi, f(xi), i = 0, 1, . . . , n} for some given function f(x) and then to evaluate
the spline at ten equally spaced points between each knot and determine the
maximum deviation between the spline and the function with respect to these