Docsity

6 Problems for Assignment 4 - Numerical Analysis II | MATH 782, Assignments of Mathematical Methods for Numerical Analysis and Optimization

Toggle sidebar
bg1
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 ti= (i−1)/(m−1), i= 1, . . . , m, and components
of ~
bgiven by bi= exp(sin(4 ∗ti)), i= 1, . . . , m.
(a) Show theoretically that the corresponding matrix A∈Rm×nhas 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 {ti}m
i=1
and then set up the matrix Ausing A(:, j) = pts. ∗A(:, j −1) for j= 2, . . . , n. Calculate
and print x(n) (the coefficient cn−1in p(t) = c0+c1t+. . . +cn−1tn−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 Land 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 Aobtained by MATLAB’s “svd(A, 0)”.
(iv) Use MATLAB’S “x=A\b” which, for A∈Rm×nwith m>n, computes the least
squares solution making use of a QR factorization of Aobtained 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∈Rm×mthere exist nonzero vectors ~
band ~
δb
such that A~x =~
b,A(~x +~
δx) = ~
b+~
δb, and k~
δxk
k~xk=κ(A)k~
δbk
k~
bk.Hint: You may want to use
the fact that for any induced matrix norm kBk= max
~z 6=~
0
kB~zk
k~zkthere exists always a particular
nonzero ~z (depending of course on B) such that kBk=kB~zk/k~zk.
Remark: This problem shows that the inequality k~
δxk
k~xk≤κ(A)k~
δbk
k~
bkis sharp.
Problem 3. Show that the problem of evaluating f(x) = (1 −cos x)/x2for 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 a3−b3=. . ..
Problem 5. Use MATLAB to compute f(x) = √x+ 1 −√xfor 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 zare floating point (computer) numbers. Show that the
algorithm of computing w=z(x+y), in which x+yis 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.

Partial preview of the text

Download 6 Problems for Assignment 4 - Numerical Analysis II | MATH 782 and more Assignments Mathematical Methods for Numerical Analysis and Optimization in PDF only on Docsity!

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

  • c 1

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.