hw4_solutions - Due: September 25, 2008 CS 257 (Luke...

Info iconThis preview shows pages 1–3. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Due: September 25, 2008 CS 257 (Luke Olson): Homework #4 Solutions Problem 1 Problem 1 In the last assignment, you implemented naive Gaussian elimination, and found out that it was lacking an important feature, row exchanges. These prevent errors from blowing up during Gaussian Elimination. We have provided a routine GE SPP that adds row exchanges to the GE naive routine from last time. We will now run GE naive , GE SPP , and Matlabs Slash for two different situations: small entry test Construct a sequence of problems for which the entries get smaller and smaller, but the condition number converges to 1.0. For this we use the identity with smaller and smaller noise, but with the matrix flipped: 1 k=5; % parameter 2 A = eye (n,n) + rand (n,n) * (10(-k)); 3 A = flipud (A); growing condition Construct a sequence of problems for which the entries stay generally contained, but the condition number grows. For this we use a built-in Matlab matrix from the gallery: 1 k=5; % parameter 2 A= gallery ( randsvd ,n,10k,2); Write 2-5 sentences commenting on the results of the two tests above using the following code. Pay particular attention to the behavior of GE naive and GE SPP versus the condition number of the matrices. Problem 1 continued on next page... Page 1 of 8 Due: September 25, 2008 CS 257 (Luke Olson): Homework #4 Solutions Problem 1 (continued) Here is the code which executes the first test (the second test is commented out). Listing 1: Test Script 1 n=50; 2 3 x=ones(n,1); 4 5 kmax = 10; 6 norms = zeros (kmax,3); 7 conds = zeros (kmax,1); 8 9 for k = 1:15 10 rand ( twister ,299); 11 12 A = eye (n,n) + rand (n,n) * (10(-k)); A = flipud (A); % first test 13 %A = gallery(randsvd,n,10k,2); % second test 14 15 b=A * x; 16 17 % perform Gaussian elimination using the naive and slash methods 18 x1=GE_naive(A,b); 19 x2=GE_SPP(A,b); 20 x3=A\b; 21 22 % compute norms of errors for each method and condition number of A 23 norms(k,:) = [ norm (x-x1) norm (x-x2) norm (x-x3)]; 24 conds(k) =...
View Full Document

Page1 / 8

hw4_solutions - Due: September 25, 2008 CS 257 (Luke...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online