Gaussian Elimination We list the basic steps of Gaussian Elimination, a method to solve a system of linear equations. Except for certain special cases, Gaussian Elimination is still “state of the art.”” After outlining the method, we will give some examples. Gaussian elimination is summarized by the following three steps: 1. Write the system of equations in matrix form. Form the augmented matrix. You omit the symbols for the variables, the equal signs, and just write the coefficients and the unknowns in a matrix. You should consider the matrix as shorthand for the original set of equations. 2. Perform elementary row operations to get zeros below the diagonal. 3. An elementary row operation is one of the following: • multiply each element of the row by a non-zero constant • switch two rows • add (or subtract) a non-zero constant times a row to another row 4. Inspect the resulting matrix and re-interpret it as a system of equations. • If you get 0 = a non-zero quantity then there is no solution. • If you get less equations than unknowns after discarding equations of the form 0=0 and if there is a solution then there is an infinite number of solutions • If you get as many equations as unknowns after discarding equations of the form 0=0 and if there is a solution then there is exactly one solution For two equations and two unknowns, the equations represent two lines. There are three possibilities: a) There is a unique solution (the lines intersect at a unique point) b) There is no solution (the two lines are parallel and don’t intersect) c) There is an infinite number of solutions (the two equations represented the same line) For three equations and three unknowns, each equations represents a plane and there are again three possibilities: a) There is a unique solution b) There is no solution c) There is an infinite number of solutions. ——————————————————————————– Examples: x+y+z 2x − y + z x+z = = = 6 3 4 First form the augmented matrix: 1 1 2 −1 1 0 1 6 1 3 1 4 Next add -2 times the first row to the second row and then add -1 times the first row to the third row: 1 1 1 6 0 −3 −1 −9 0 −1 0 −2 Next multiply the second row by −1 and the third row by −1, just to get rid of the minus signs. Then switch the second and third rows: 1 0 0 1 1 1 0 3 1 6 2 9 Now add −3 times the second row to the third row, so we have all zeros below the diagonal: 1 0 0 1 1 0 1 0 1 6 2 3 Now re-interpret the augmented matrix as a system of equations, starting at the bottom and working backwards (this is called back substitution). The bottom equation is 0x + 0y + z = 3 so z = 3. The next to the bottom equation is 0x + y + 0z = 2 so y = 2. The next equation (the top one) is x + y + z = 6. Substitute the values z = 3 and y = 2 into the equation and get x = 1. ——————————————————————————– Next example: x+y+z 2x − y + z x+z 2x + y + z = 6 = 3 = 4 = 7 Form the augmented matrix: 1 1 1 6 2 −1 1 3 1 0 1 4 2 1 1 7 Add −2 times the first row to the second, −1 times the first to the third, and −2 times the first to the fourth to get 0’s in the first column below the diagonal. 1 1 1 6 0 −3 −1 −9 0 −1 0 −2 0 −1 −1 −5 Multiply the second, third, and fourth equations by −1 and then switch the second and third equations to avoid fractions; 1 0 0 0 1 1 3 1 1 0 1 1 6 2 9 5 Now add −3 times the second row to the third row, and add −1 times the second row to the fourth row. 1 0 0 0 1 1 0 0 1 0 1 1 6 2 3 3 1 0 1 0 6 2 3 0 Now add −1 times the third row to the fourth row. 1 0 0 0 1 1 0 0 Re-interpret the matrix as a system of equations. The bottom equation says 0x + 0y + 0z = 0, i.e., 0 = 0. We can discard this equation since we already knew that, and use back substitution as before, to get z = 3, y = 2, x = 1. ——————————————————————————– Next example: x+y+z 2x − y + z x+z 2x + y + z = = = = 6 3 4 8 Form the augmented matrix: 1 1 2 −1 1 0 2 1 1 6 1 3 1 4 1 8 Row reduce the augmented matrix as in the previous example. After those steps, you get 1 0 0 0 1 1 0 0 1 0 1 0 6 2 3 1 Re-interpret the matrix as a system of equations. The last row yields 0x + 0y + 0z = 1, i.e., that 0 = 1. But this is impossible, so we know that there is no set of numbers x,y,z that satisfy all the equations, in other words, there is no solution. ——————————————————————————– Next problem: x+y+z 2x − y + z 2x + 2y + 2z = 6 = 3 = 12 Pretend you didn’t notice that the third equation is equivalent to the first equation for a moment. Form the augmented matrix 1 1 2 −1 2 2 1 1 2 6 3 12 Next add −2 times the first row to the second row and then add −2 times the first row to the third row: 1 1 1 6 0 −3 −1 −9 0 0 0 0 The last row, interpreted as an equation, merely says that 0 = 0, so as before we discard that. The next equation says −3y − z = −9, or y = (9 − z)/3, and then x = 6 − y − z = 6 = (9 − z)/3 − z = 3 − (2/3)z, so there is an infinite number of solutions. ——————————————————————————– Solving a set of n equations with n unknowns when there is a unique solution; checking your work: Graphing calculators can solve small sets of equations. Each calculator is different, so you need to check your manual. If you have a TI83 click here. If you have an HP38G click here. ——————————————————————————– Checking your work with Excel: First method: For an Excel program to solve a linear system, click here. Practice using a previous example: x+y+z 2x − y + z x+z = = = 6 3 4 First form the augmented matrix: 1 6 1 3 1 4 1 1 2 −1 1 0 Check that you get the answer x = 1, y = 2, z = 3. Second method: (not as easy, but you don’t need a program to do it this way.) This method uses the idea of the inverse of a matrix A. If the matrix equation AX=B has a unique solution then there is another matrix, A−1 , called the inverse of A, also written inverse(A), so that X = A−1 B, i.e., the solution X is the matrix product of A−1 and B. Depending on how the inverse is formed, this method can be very inefficient. There is usually no advantage to forming the inverse of the matrix A. We mention this method because the Excel function MINVERSE allows you to form the inverse of A. Hence given a matrix equation AX=B, you can use Excel first to compute A−1 , and then to compute A−1 B. Given a matrix equation Ax=B, enter the matrix in your worksheet. For example, suppose the set of equations is x +2y = 3 3x +4y = 7 Our matrix A is then 1 3 2 4 Enter this matrix at the upper left hand corner so A1=1, B1=2, A2=3, B2=4. Now at a convenient place, say at A3, click on the cell and paste in the formula MINVERSE (under math & trig) The array you enter this time will be a1:b2 (the upper left corner and lower right corner of the array). Click OK. Then highlight where you want all the matrix A−1 to appear. So you have A3, B3, A4, B4 highlighted. Then use the previous trick: hit F2, then hit Ctrl, Shift, Enter at the same time. You should now have the matrix −2 1 1.5 −.5 with upper left corner at A3. Put the 2 by 1 matrix B (also called a column vector) 3 7 Next to the inverse matrix, so C3=3 and C4=7. Now multiply the Inverse matrix A−1 and B (using MMULT with first array=a3:b4 and second array = c3:c4), and you should get a final answer of Which means our final solution is x = 1, y = 1. 1 1