Problem 8

Section 8.2

Problems 2,3,5,7

For #2, also do n=50 and 100. For each value of n, you know the exact answer, x_true. For each value of n, present max(|x_i - (x_true)_x|). Also find Ax-b and present max(|(Ax)_i - b_i|).
For #3, also do n=50 and 100. For each value of n, you know the exact answer, x_true. For each value of n, present max(|x_i - (x_true)_x|). Also find Ax-b and present max(|(Ax)_i - b_i|).

Problem 1:

Create a subroutine "pivot.m" which takes in A, b, and k and returns A and b. It looks at the entries A(k,k), A(k+1,k), ... A(n,k) and finds which one is greatest in magnitude. It then switches that row and the kth row. It also switches the respective two entries in the vector b.

Show that your subroutine works by testing it on A = [1,2,3;-7,8,9;4,5,6] and b = [1;2;3] for both k=1 and k=2.

Problem 2:

Put your pivot routine into my "gauss_elim.m" routine so that it does Gaussian elimination with pivoting.

For n = 2, 5, 10, 20, 50, 100, pick a random n x n matrix A and n x 1 matrix b Find the solution x_p by using Gaussian elimination with pivoting. Now find the solution x_np by using Gaussian elimination without pivoting. MAKE SURE NOT TO PICK A NEW MATRIX, JUST RECOMPUTE x_np!

For each value of n, present max( |(A x_p)_i - b_i|) and max( |(A x_np)_i - b_i|). What do you find?

Does this shed any light on the behavior you found in #2?