
Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!

Math 782, HW 4, DUE Wednesday, March 28
For problems involving MATLAB, turn in printouts of your m-files, obtained numerical
results and your own discussion. Use format long e of MATLAB to display your results.
Problem 1. Consider polynomial least squares fitting (see your notes or Example 11.2 in
the text) with m = 100, n = 15, points t i
= (i − 1)/(m − 1), i = 1,... , m, and components
of
b given by b i
= exp(sin(4 ∗ t i
)), i = 1,... , m.
(a) Show theoretically that the corresponding matrix A ∈ R
m×n has rank n. Hint: Use the
fact that any nonzero polynomial of degree ≤ n − 1 has at most n − 1 distinct roots.
(b) Use MATLAB’s “linspace” to set up the column vector pts containing the points {t i
m
i=
and then set up the matrix A using A(:, j) = pts. ∗ A(:, j − 1) for j = 2,... , n. Calculate
and print x(n) (the coefficient c n− 1
in p(t) = c 0
t +... + c n− 1
t
n− 1 ) by the following 4
methods:
(i) Form and then solve the system of normal equations using MATLABS’s “chol” and your
own functions “~x =forsub(L,
b)” and “~x =bacsub(U,
b)” that perform respectively forward
substitution for a lower triangular L and backward substitution for an upper triangular U.
(ii) Use Matlab’s “[Q, R] =qr(A, 0)” (to obtain a reduced QR factorization of A) and your
own function “~x =bacsub(U,
b)”.
(iii) Use a reduced SVD of A obtained by MATLAB’s “svd(A, 0)”.
(iv) Use MATLAB’S “x = A\b” which, for A ∈ R
m×n with m > n, computes the least
squares solution making use of a QR factorization of A obtained by Householder transfor-
mations with column pivoting.
Remember to print x(n) only. Do not print A,
b, or any intermediate matrices. Using the
exact value x(n) = 2. 006787453080206.. .e+03, determine the number of correct significant
digits in x(n) computed by the methods (i)–(iv).
To make sure that your code (i) works correctly, test (i) and (ii) for m = 10 and n = 5.
You should obtain similar values of x(n) which are to be printed and submitted.
Problem 2. Show that for any nonsingular A ∈ R
m×m there exist nonzero vectors
b and
δb
such that A~x =
b, A(~x +
δx) =
b +
δb, and
δx‖
‖~x‖
= κ(A)
δb‖
b‖
. Hint: You may want to use
the fact that for any induced matrix norm ‖B‖ = max
~z 6 =~ 0
‖B~z‖
‖~z‖
there exists always a particular
nonzero ~z (depending of course on B) such that ‖B‖ = ‖B~z‖/‖~z‖.
Remark: This problem shows that the inequality
δx‖
‖~x‖
≤ κ(A)
δb‖
b‖
is sharp.
Problem 3. Show that the problem of evaluating f (x) = (1 − cos x)/x
2 for x ≈ 0 is well-
conditioned. Find a stable way to compute f (x) for x ≈ 0 in floating point arithmetic.
Hint: Use an appropriate trig identity or Taylor’s theorem.
Problem 4. Repeat problem 3 for f (x) = (1 + x)
1 / 3
− 1, x ≈ 0. Hint: Use a
3
− b
3
=.. ..
Problem 5. Use MATLAB to compute f (x) =
x + 1 −
x for x = (100)
i , i = 1, 2 , 3 , 4 , 5,
using two methods: (i) directly from the definition of f (x); (ii) a stable method, similar
to the one presented in class for f (x) =
x + 1 − 1 and x ≈ 0. Comment on the obtained
results.
Problem 6. Assume that x, y, and z are floating point (computer) numbers. Show that the
algorithm of computing w = z(x + y), in which x + y is computed first, is backward stable.
Derive directly, in terms of the unit round off u (equivalently machine ), an upper bound
on the relative error in the computed value of w.