The following file has been edited and some comments have been added. The goal is to find all the solutions (if any) of a system of linear equations of the form ___________ | A*X = b | ----------- using Gaussian elimination and in particular the commands rref(c) or Here c = [A b] is the augmented matrix. rrefmovie(c) The output of this command is a "reduced row echelon form" of the augmented matrix "c". It is up to you then to find the solutions (if any) of the system. ****************************************************************************** < M A T L A B (R) > (c) Copyright 1984-94 The MathWorks, Inc. All Rights Reserved Version 4.2c Nov 23 1994 matCommands to get started: intro, demo, help help Commands for more information: help, whatsnew, info, subscribe In this example the coefficient matrix A is a 4x5 matrix. The Gaussian elimination method will allow us to determine all the solutions (there are an infinite number) >> A=[1 1 -1 0 1; -1 -1 2 -1 1; 2 2 -3 3 1; 1 1 0 -3 2] A = 1 1 -1 0 1 -1 -1 2 -1 1 2 2 -3 3 1 1 1 0 -3 2 >> b=[1; 2; 0; 3] b = 1 2 0 3 >> c=[A b] c = 1 1 -1 0 1 1 -1 -1 2 -1 1 2 2 2 -3 3 1 0 1 1 0 -3 2 3 >> rrefmovie(c) Original matrix A = 1 1 -1 0 1 1 -1 -1 2 -1 1 2 2 2 -3 3 1 0 1 1 0 -3 2 3 Press any key to continue. . . swap rows 1 and 3 A = 2 2 -3 3 1 0 -1 -1 2 -1 1 2 1 1 -1 0 1 1 1 1 0 -3 2 3 Press any key to continue. . . pivot = A(1,1) A = 1 1 -3/2 3/2 1/2 0 -1 -1 2 -1 1 2 1 1 -1 0 1 1 1 1 0 -3 2 3 eliminate in column 1 A = 1 1 -3/2 3/2 1/2 0 0 0 1/2 1/2 3/2 2 1 1 -1 0 1 1 1 1 0 -3 2 3 A = 1 1 -3/2 3/2 1/2 0 0 0 1/2 1/2 3/2 2 0 0 1/2 -3/2 1/2 1 1 1 0 -3 2 3 A = 1 1 -3/2 3/2 1/2 0 0 0 1/2 1/2 3/2 2 0 0 1/2 -3/2 1/2 1 0 0 3/2 -9/2 3/2 3 Press any key to continue. . . column 2 is negligible A = 1 1 -3/2 3/2 1/2 0 0 0 1/2 1/2 3/2 2 0 0 1/2 -3/2 1/2 1 0 0 3/2 -9/2 3/2 3 Press any key to continue. . . swap rows 2 and 4 A = 1 1 -3/2 3/2 1/2 0 0 0 3/2 -9/2 3/2 3 0 0 1/2 -3/2 1/2 1 0 0 1/2 1/2 3/2 2 Press any key to continue. . . pivot = A(2,3) A = 1 1 -3/2 3/2 1/2 0 0 0 1 -3 1 2 0 0 1/2 -3/2 1/2 1 0 0 1/2 1/2 3/2 2 eliminate in column 3 A = 1 1 0 -3 2 3 0 0 1 -3 1 2 0 0 1/2 -3/2 1/2 1 0 0 1/2 1/2 3/2 2 A = 1 1 0 -3 2 3 0 0 1 -3 1 2 0 0 0 0 0 0 0 0 1/2 1/2 3/2 2 A = 1 1 0 -3 2 3 0 0 1 -3 1 2 0 0 0 0 0 0 0 0 0 2 1 1 Press any key to continue. . . swap rows 3 and 4 A = 1 1 0 -3 2 3 0 0 1 -3 1 2 0 0 0 2 1 1 0 0 0 0 0 0 Press any key to continue. . . pivot = A(3,4) A = 1 1 0 -3 2 3 0 0 1 -3 1 2 0 0 0 1 1/2 1/2 0 0 0 0 0 0 eliminate in column 4 A = 1 1 0 0 7/2 9/2 0 0 1 -3 1 2 0 0 0 1 1/2 1/2 0 0 0 0 0 0 A = 1 1 0 0 7/2 9/2 0 0 1 0 5/2 7/2 0 0 0 1 1/2 1/2 0 0 0 0 0 0 A = 1 1 0 0 7/2 9/2 0 0 1 0 5/2 7/2 0 0 0 1 1/2 1/2 0 0 0 0 0 0 Press any key to continue. . . column 5 is negligible A = 1 1 0 0 7/2 9/2 0 0 1 0 5/2 7/2 0 0 0 1 1/2 1/2 0 0 0 0 0 0 Press any key to continue. . . column 6 is negligible A = _____ | 1 | 1 0 0 7/2 9/2 |___| _____ 0 0 | 1 | 0 5/2 7/2 |___| _____ 0 0 0 | 1 | 1/2 1/2 |___| 0 0 0 0 0 0 a) The system is consistent; moreover since there are no leading ones on the second and fifth column, we know that the variable "x_2" and "x_5" are the "free variables" and we also know that we can express "x_1", "x_3", and "x_4" in terms of "x_2" and "x_5". x_1 = 9/2 - x_2 - 7/2 x_5 x_2 = free variable x_3 = 7/2 - 5/2 x_5 x_4 = 1/2 - 1/2 x_5 x_5 = free variable b) We can also write the general solution in vector form [ x_1 ] [ 9/2 ] [ -1 ] [ -7/2 ] [ ] [ ] [ ] [ ] [ x_2 ] [ 0 ] [ 1 ] [ 0 ] [ ] [ ] [ ] [ ] [ x_3 ] = X_p + x_2*X_2 + x_5*X_5 = [ 7/2 ] + x_2*[ 0 ] + x_5*[ -5/2 ] [ ] [ ] [ ] [ ] [ x_4 ] [ 1/2 ] [ 0 ] [ -1/2 ] [ ] [ ] [ ] [ ] [ x_5 ] [ 0 ] [ 0 ] [ 1 ] Also, note that X_p is a particular solution of the system AX=b, while x_2*X_2+x_5*X_5 describes all the solutions of the homogeneous system AX=0.