




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 433 - Numerical Analysis - Spring 2008 Homework 7:SOLUTIONS Assigned: Friday, March 7, 2008. Due: Friday, March 21, 2008.
Show that the l 1 vector norm satisfies the three properties
(a) ||x|| 1 ≥ 0 for x ∈ Rn^ and ||x|| = 0 if and only if x = 0 (b) ||λx|| 1 = |λ| ||x|| 1 for λ ∈ R and x ∈ Rn (c) ||x + y|| 1 ≤ ||x|| 1 + ||y|| 1 for x, y ∈ Rn
A =
Compute ‖A‖∞ and find a vector x such that ‖A‖∞ = ‖Ax‖∞/‖x‖∞. (b) Find an example of a 2 × 2 matrix A such that ‖A‖∞ = 1 but ρ(A) = 0. This shows that the spectral radius ρ(A) = {max |λ| : λ is an eigenvalue of A} does not define a matrix norm.
, b =
, x 1 =
, x 2 =
(a) Show that x = (2, −2)T^ is the exact solution of Ax = b. (b) Compute the error and residual vectors for x 1 and x 2. (c) Find ||A||∞, ||A−^1 ||∞ and cond∞(A) (you may use MATLAB for this cal- culation). (d) In class we proved a theorem relating the condition number of A, the relative error, and the relative residual. Check this result for the two approximate solutions x 1 and x 2.
The Rockmore Corp. is the considering the purchase of a new computer and will choose either the DoGood 174 or the MightDo 11. They test both computers’ ability to solve the linear system
34 x + 55y − 21 = 0 55 x + 89y − 34 = 0
The DoGood 174 computer gives x = − 0 .11 and y = 0.45, and its check for accuracy is found by substitution:
34(− 0 .11) + 55(0.45) − 21 = 0. 01 55(− 0 .11) + 89(0.45) − 34 = 0. 00 The MightDo 11 computer gives x = − 0 .99 and y = 1.01, and its check for accuracy is found by substitution:
Which computer gave the better answer? Why?
(a) Write a program that takes the output A and p from your hw 6, along with a righthand side b, and computes the solution of Ax = b by performing the forward and backward substitution steps. If you are using MATLAB, name your m-file lusolve.m. The first line of your code lusolve.m should be as follows: function x=lusolve(a,p,b) (your code here!) Turn in a copy of your code. (b) The famous Hilbert matrices are given by Hij = 1/(i + j − 1). The n × n Hilbert matrix Hn is easily produced in MATLAB using hilb(n). Assume the true solution of Hnx = b for a given n is x = [1,... , 1]T^. Hence the righthand side b is simply the row sums of Hn, and b is easily computed in MATLAB using b=sum(hilb(n)’)’. Use your codes mylu.m and lusolve.m to solve the system Hnx = b for n = 5, 10 , 15 , 20. For each n, using the ∞− norm, compute the relative error and the relative residual. Discuss what is happening here. You may find it useful to look at the cond command in MATLAB.
Problem 5
pr5_hilb n=5, relative error =5.1295e-12, relative residual =4.8623e- cond(hilb(5))=9.4366e+
n=10, relative error =0.00053822, relative residual =1.5162e- cond(hilb(10))=3.5354e+
n=15, relative error =5.62, relative residual =1.3383e- cond(hilb(15))=8.0290e+
n=20, relative error =31.1286, relative residual =1.8515e- cond(hilb(20))=5.6439e+
Condition number of the Hilbert matrix is large, i.e. Hilbert matrix is highly ill-conditioned, therefore results may be inaccurate especially for higher dimensions since condition number increases with dimension. The above computations are done using Matlab, so actual results using mylu.m code may be different depending on the program and computer used. In any event, the accuracy should deteriorate with n. From the above computations we see that the relative error increases with n, while relative residual stays small. This is in agreement with the error bound result: relative error is bounded by condition # times relative residual
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% % pr5_hilb.m %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
clear all
n=5; for i=1: xex=ones(1,n)’;
A=hilb(n); b=sum(hilb(n)’)’; x=A\b; rel_e=norm(xex-x,inf)/norm(xex,inf); rel_r=norm(b-A*x,inf)/norm(b,inf); disp([’n=’,num2str(n),’, relative error =’,num2str(rel_e),’, relative residual =’,num2st disp([’cond(hilb)=’,num2str(cond(A,inf),’%2.4e’)])
disp([’ ’]) disp([’ ’]) disp([’ ’])
n=n+5; end