Solve Ax=b, where A is an n n matrix and b is an n 1 column vector We can also talk about non-square systems where A is m n, b is m 1, and x is n 1 – Overdetermined if m>n: “ more equations than unknowns ” – Underdetermined if n>m: “ more unknowns than equations ”
Singular Systems A is singular if some row is linear combination of other rows Singular systems can be underdetermined: or inconsistent:
Using Matrix Inverses To solve Ax = b it would be nice to use the inverse to A, that is, A -1 However, it is usually not a good idea to compute x=A -1 b – Inefficient – Prone to roundoff error
Gaussian Elimination Fundamental operations: 1.Replace one equation with linear combination of other equations 2.Interchange two equations 3.Multiply one equation by a scalar These are called elementary row operations. Do these operations again and again to reduce the system to a “ trivial ” system
Triangular Form Two special forms of matrices are especially nice for solving Ax=b: In both cases, successive substitution leads to a solution
Matlab – Partial Pivoting Partial Pivoting: At step k, we are working on kth row, pivot = A kk. Search for largest A ik in kth column below (and including) A kk. Let p = index of row containing largest entry. If p ≠ k, swap rows p and k. Continue with Gaussian Elimination.
Matlab – Partial Pivoting Finding largest entry in a column: >> A A = 2 1 1 3 4 4 0 7 6 5 4 17 2 -1 0 7 >> [r,m] = max(A(2:4,2)) r = 5 m = 2 Why isn’t m = 3?
Matlab – Partial Pivoting Code change? All that is needed is in main loop (going from rows k ->n-1) we add % Find max value (M) and index (m) of max entry below AAkk [M,m] = max(abs(AA(k:n,k))); m = m + (k-1); % row offset % swap rows, if needed if m ~= k, AA([k m],:) = AA([m k],:); end
Matlab – Partial Pivoting Class Exercise Review example in Moler Section 2.6