Docsity

Assignment 3 - Computational Methods - Fall 2001 | MAPL 460, Assignments of Mathematics

Toggle sidebar
bg1
CMSC/MAPL 460 Dr. Wolfe ASSIGNMENT #3 Due March 26, 2001
1. The Runge function is
r(x) = 1
1 + x2,−5≤x≤5.
(a) For n= 5,10,15, plot pn(x), the polynomial interpolating r(x) at n+ 1 equally
spaced points, along with the graph of r(x). Use the MATLAB functions POLY-
FIT and POLYVAL. Observe what is happening to the graphs. Where is the
polynomial fit getting better ? Where is it getting worse ?
(b) Repeat part (a) but now use the interpolation points
xj= 5 cos (2j−1)π
2n+ 2 , j = 1,...,n+ 1.
What difference do you observe ?
2. Ex. 3.4, p.90, Shampine, Allen & Preuss. (Just use the MATLAB backslash operator.)
3. Ex. 3.10, p.90, Shampine, Allen & Preuss.
4. For f(x) = sinh xwe are given that
f(0) = 0, f0(0) = 1, f(1) = 1.1752, f 0(1) = 1.5431.
Calculate an approximation to f(0.5) using cubic Hermite interpolation. Compare
the result with f(0.5) = .5211.
5. Ex. 3.15, p.98, Shampine, Allen & Preuss.
6. Consider the function S(x) defined as
S(x) =
28 + 25x+ 9x2+x3,−3≤x≤ −1,
26 + 19x+ 3x2−x3,−1≤x≤0,
26 + 19x+ 3x2−2x3,0≤x≤3,
−163 + 208x−60x2+ 5x3,3≤x≤4.
Show that S(x) is a natural cubic spline function with the knots {−3,−1,0,3,4}. (A
natural cubic spline is a spline S(x) which satisfies S00(x1) = S00(xN) = 0) Be sure to
state explicitly each of the properties of S(x) which are necessary for this to be true.
7. Ex. 3.22, p.115, Shampine, Allen & Preuss. Use the MATLAB function SPLINE.
8. Take the data set from Ex. 3.22 and find and plot the polynomials of degree 2, 3
and 4 which best fit this data in the sense of least squares. The MATLAB functions
POLYVAL and POLYFIT give you exactly what you need.
9. For the data of problem 7 find the cubic polynomial p3(x) = p0+p1x+p2x2+p3x3
interpolating the data in the sense of least squares by constructing the 11 ×4 data
matrix Aand finding the vector (p0, p1, p2, p3)Tin four different ways:
(a) By using the backslash operator.
(b) By forming and solving the normal equations. Note the condition number of the
matrix ATA.
(c) By using the QR decomposition.
(d) By using the Singular-Value Decomposition.
All of this is quite easy in MATLAB. Compare with the values found in problem 8.

Partial preview of the text

Download Assignment 3 - Computational Methods - Fall 2001 | MAPL 460 and more Assignments Mathematics in PDF only on Docsity!

CMSC/MAPL 460 Dr. Wolfe ASSIGNMENT #3 Due March 26, 2001

  1. The Runge function is r(x) =

1 + x^2

, − 5 ≤ x ≤ 5.

(a) For n = 5, 10 , 15, plot pn(x), the polynomial interpolating r(x) at n + 1 equally spaced points, along with the graph of r(x). Use the MATLAB functions POLY- FIT and POLYVAL. Observe what is happening to the graphs. Where is the polynomial fit getting better? Where is it getting worse? (b) Repeat part (a) but now use the interpolation points

xj = 5 cos

(2j − 1)π 2 n + 2

, j = 1,... , n + 1.

What difference do you observe?

  1. Ex. 3.4, p.90, Shampine, Allen & Preuss. (Just use the MATLAB backslash operator.)
  2. Ex. 3.10, p.90, Shampine, Allen & Preuss.
  3. For f (x) = sinh x we are given that f (0) = 0, f ′(0) = 1, f (1) = 1. 1752 , f ′(1) = 1. 5431. Calculate an approximation to f (0.5) using cubic Hermite interpolation. Compare the result with f (0.5) = .5211.
  4. Ex. 3.15, p.98, Shampine, Allen & Preuss.
  5. Consider the function S(x) defined as

S(x) =

28 + 25x + 9x^2 + x^3 , − 3 ≤ x ≤ − 1 , 26 + 19x + 3x^2 − x^3 , − 1 ≤ x ≤ 0 , 26 + 19x + 3x^2 − 2 x^3 , 0 ≤ x ≤ 3 , −163 + 208x − 60 x^2 + 5x^3 , 3 ≤ x ≤ 4. Show that S(x) is a natural cubic spline function with the knots {− 3 , − 1 , 0 , 3 , 4 }. (A natural cubic spline is a spline S(x) which satisfies S′′(x 1 ) = S′′(xN ) = 0) Be sure to state explicitly each of the properties of S(x) which are necessary for this to be true.

  1. Ex. 3.22, p.115, Shampine, Allen & Preuss. Use the MATLAB function SPLINE.
  2. Take the data set from Ex. 3.22 and find and plot the polynomials of degree 2, 3 and 4 which best fit this data in the sense of least squares. The MATLAB functions POLYVAL and POLYFIT give you exactly what you need.
  3. For the data of problem 7 find the cubic polynomial p 3 (x) = p 0 + p 1 x + p 2 x^2 + p 3 x^3 interpolating the data in the sense of least squares by constructing the 11 × 4 data matrix A and finding the vector (p 0 , p 1 , p 2 , p 3 )T^ in four different ways: (a) By using the backslash operator. (b) By forming and solving the normal equations. Note the condition number of the matrix AT^ A. (c) By using the QR decomposition. (d) By using the Singular-Value Decomposition. All of this is quite easy in MATLAB. Compare with the values found in problem 8.