Docsity

Numerical Computing Homework 5 - MATH/CSCI 4800-01 - Prof. Ashwani K. Kapila, Assignments of Computer Science

Toggle sidebar
bg1
Numerical Computing S’09 MATH/CSCI 4800-01
Homework-5
Due in class on Monday March 23, 2009
Illegible reports will be returned without grading. Show all work. All Matlab scripts, Matlab output and
plots should be printed out and stapled to the report.
1. (Pencil-and-paper)
(a) Define natural, clamped and not-a-knot cubic splines.
(b) Check whether the following function is a natural cubic spline. If it is not, then indicate the
reason for the breakdown.
S(x) =
28 + 25x+ 9x2+x3x∈[−3,−1]
26 + 19x+ 3x2−x3x∈[−1,0]
26 + 19x+ 3x2−2x3x∈[0,3]
−163 + 208x−60x2+ 5x3x∈[3,4]
2. (Pencil-and-paper and Matlab) In class we examined the Chebyshev interpolation procedure of con-
structing polynomial interpolants to a function; see section 3.3 of the Text as well as class notes.
Assume that the Chebyshev procedure is to be used to construct a 5-th degree interpolant p(x) to
f(x) = ln xon the interval [2,6].
(a) Write down the (x, y) points that will serve as the interpolation nodes for p(x).
(b) Write a Matlab script to compute p(x) and plot a graph showing both pand fon the interval
[2,6].(You may use the Matlab commands polyfit and polyval.) Comment on the eyeball-
accuracy of your result.
(c) Find, analytically, the upper bound on the interpolation error |ln x−p(x)|that is valid for all
xin [2,6].
(d) Based upon the above estimate, how many digits will be correct when p(4) is used to approximate
ln 4? Check your result against the exact answer and comment.
3. (Pencil-and-paper and Matlab)
(a) Section 3.1.2 of the Text discusses the use of Newton divided differences to construct polynomial
interpolants. Use the Matlab code segments provided in that section to find the coefficients of
the Newton interpolant, p(x),for the following data.
x y
0 32
1 4.0
2 5.6
3 7.1
4 8.4
5 10.1
6 11.5
7 13.1
8 14.4
9 16.1
10 17.5
(b) Construct a cubic spline interpolant, s(x),to the data in part (a) by using the Matlab spline
command.
pf2

Partial preview of the text

Download Numerical Computing Homework 5 - MATH/CSCI 4800-01 - Prof. Ashwani K. Kapila and more Assignments Computer Science in PDF only on Docsity!

Numerical Computing S’09 MATH/CSCI 4800- Homework-

Due in class on Monday March 23, 2009

Illegible reports will be returned without grading. Show all work. All Matlab scripts, Matlab output and plots should be printed out and stapled to the report.

  1. (Pencil-and-paper)

(a) Define natural, clamped and not-a-knot cubic splines. (b) Check whether the following function is a natural cubic spline. If it is not, then indicate the reason for the breakdown.

S(x) =

28 + 25x + 9x^2 + x^3 x ∈ [− 3 , −1] 26 + 19x + 3x^2 − x^3 x ∈ [− 1 , 0] 26 + 19x + 3x^2 − 2 x^3 x ∈ [0, 3] −163 + 208x − 60 x^2 + 5x^3 x ∈ [3, 4]

  1. (Pencil-and-paper and Matlab) In class we examined the Chebyshev interpolation procedure of con- structing polynomial interpolants to a function; see section 3.3 of the Text as well as class notes. Assume that the Chebyshev procedure is to be used to construct a 5-th degree interpolant p(x) to f (x) = ln x on the interval [2, 6].

(a) Write down the (x, y) points that will serve as the interpolation nodes for p(x). (b) Write a Matlab script to compute p(x) and plot a graph showing both p and f on the interval [2, 6]. (You may use the Matlab commands polyfit and polyval.) Comment on the eyeball- accuracy of your result. (c) Find, analytically, the upper bound on the interpolation error | ln x − p(x)| that is valid for all x in [2, 6]. (d) Based upon the above estimate, how many digits will be correct when p(4) is used to approximate ln 4? Check your result against the exact answer and comment.

  1. (Pencil-and-paper and Matlab)

(a) Section 3.1.2 of the Text discusses the use of Newton divided differences to construct polynomial interpolants. Use the Matlab code segments provided in that section to find the coefficients of the Newton interpolant, p(x), for the following data.

x y 0 32 1 4. 0 2 5. 6 3 7. 1 4 8. 4 5 10. 1 6 11. 5 7 13. 1 8 14. 4 9 16. 1 10 17. 5

(b) Construct a cubic spline interpolant, s(x), to the data in part (a) by using the Matlab spline command.

(c) On a single, labelled graph with appropriate legends, display the discrete data points, the piecewise linear interpolant, the polynomial interpolant computed in part (a) and the spline interpolant computed in part (b). List the advantages and disadvantages of each. Which of the three do you prefer and why?

  1. (Pencil-and-paper and Matlab)

(a) Solve Text Problem 2a, Exercises 4.1, page 204 by hand, using the procedure outlined in Example 4.4 on page 200. (b) (Extra Credit) Solve the above problem by hand by using the QR decomposition. This will require adding an extra column to the 4 × 3 matrix, employing Gram-Schmidt orthogonalization to generate Q and R, and then using the procedure outlined on page 222 to solve the least- squares problem. (c) Solve the problem with Matlab by using the QR decomposition. You may find the code segment given in Example 4.15 on page 223 helpful.

  1. (Extra Credit) Text Problem 5, Computer Problems 4.1, page 205. You may use any method to obtain the least-squares fit, including appropriate Matlab commands.