Problem 1 - Gaussian Elimination

  1. Consider the $ 3 \times 3$ matrix A = [ 0 -1 2; 1 -1 0; 3 1 -1] and the (column) vector b = [ 7; 3; 2], and solve $ A x = b$ using Gaussian elimination (by hand computation). Check your solution by computing A * x, to see that you get the result b, and compare to Matlab's A b.

    Construct the matrix S = [A, b] representing the linear system. The function rref(B) (where B is a matrix) computes the resulting matrix of Gaussian elimination. If you have trouble understanding what it does, try rrefmovie(S) on your linear system S.

    Note that there are two variants of Gaussian elimination:

    The first variant, described in the AMBS book, stops when the matrix A in the system S has been transformed into a triangular matrix. It is then possible to simply substitute the values in starting from the bottom to get the solution x.

    The second variant, which rref(B) uses, continues and transforms the matrix A in the system S into a diagonal matrix with ones on the diagonal (this matrix is called the identity matrix). The solution x is then simply the column vector to the right in S.

  2. Solve (by hand) the equation system $ A x = b$ where A = [ 1 2 3; -2 -4 3; 3 1 0] and b = [ 7; 13; -6]. Check your answer with rref([A b]). Compare with the operation A \ b.

  3. Solve using matlab $ A x = b$ with A the same as in 2, b = e1 = [ 1; 0; 0], b = e2 = [ 0; 1; 0] and b = e3 = [ 0; 0; 1], respectively. Denote the solutions by x1, x2 and x3 , and put the three solutions together to form the matrix C = [x1 x2 x3], and verify that $ A C = I = (e_1, e_2, e_3)$. Recall that the matrix C is called the inverse of A , and is denoted by $ A^{-1}$, or inv(A) in Matlab syntax, that is C == inv(A).

    Now compute inv(A) * b , with b as in 2 , and note that this gives the solution to $ A x = b$. Why?

  4. Compute the determinant det(A) of A (check by hand computation), that is the volume spanned by the three column vectors of A, (see section 21.11 of AMBS). Note that this number determines if the linear system of equations $ A x = b$ has a unique solution or not for all b. Is this the case for the A under consideration ?

  5. Consider now a singular matrix, for example A = [ 2 1 -1; 1 3 0; 0 -5 -1], where the second column is a linear combination of the first and third one (can you see how?). Likewise the second row is a combination of the first and third. Now seek to solve $ A x = b$ with b = [ 1; 2; 3] using Gaussian elimination. What happens? Compute the determinant of A and try to explain the result to a comrade.

    Try solving the same system using the Matlab \ operator. How do you interpret Matlabs answer? Is there an inverse matrix such that $ A^{-1} A = I$ (inv(A) * A == I in Matlab syntax)?

Johan Jansson 2004-10-04