Systems of Linear Equations Consider the following example of a system of equations: \begin{align*} 2x + y &= 5 \quad \text{(Row 1)} \\ x - y &= 7 \quad \text{(Row 2)} \end{align*} To solve for x and y , we start by adding the two equations. This will eliminate the y variable. \begin{align*} 3x &= 12 \\ x &= 4 \end{align*} Then substituting back to find y ; \begin{align*} 4 - y &= 7 \\ y &= -3 \end{align*} In the above process, we used the following "row operation". \text{Row 2} \leftarrow \text{Row 2} + \text{Row 1} Replacing row 2 with row 1 + row 2. This gives; \begin{align*} 2x + y &= 5 \\ 3x &= 12 \end{align*} We will now examine this "row operation" process and put it into perspective. Row Operations on systems of equations Consider the following example. \begin{align*} 3x_1 - 2x_2 + x_3 &= 5 \\ x_1 + 2x_2 + 3x_3 &= 7 \\ 2x_1 - x_2 + 2x_3 &= 11 \end{align*} Three things that we can do on the system of equations, without harming or changing its solutions (we'll change individual equations, but without changing the solutions): 1. Swap the order of equations Example: Swap equation 1 and equation 2 in the system. \begin{align*} x_1 + 2x_2 + 3x_3 &= 7 \\ 3x_1 - 2x_2 + x_3 &= 5 \\ 2x_1 - x_2 + 2x_3 &= 11 \end{align*} 2. Multiply an equation by a non-zero number Example: Multiply equation 3 by 2 in the system. 2(2x_1 - x_2 + 2x_3) = 2 \cdot 11 \Rightarrow 4x_1 - 2x_2 + 4x_3 = 22 So we get the following system of equations, \begin{align*} 3x_1 - 2x_2 + x_3 &= 5 \\ x_1 + 2x_2 + 3x_3 &= 7 \\ 4x_1 - 2x_2 + 4x_3 &= 22 \end{align*} 3. Multiply an equation by a number and add it to another equation Example: Multiply equation 1 by -2 and add it to equation 2, replacing equation 2 in the system. x_1 + 2x_2 + 3x_3 + (-2)(3x_1 - 2x_2 + x_3) = 7 + (-2) \cdot 5 \Rightarrow -5x_1 + 6x_2 + x_3 = -3 So we get the following system of equations, \begin{align*} 3x_1 - 2x_2 + x_3 &= 5 \\ -5x_1 + 6x_2 + x_3 &= -3 \\ 2x_1 - x_2 + 2x_3 &= 11 \end{align*} Augmented Matrix - A Different Way of Writing the Equations Notice that the solutions depend only on the numbers; the variables are irrelevant - they are just 'placeholders'. So we can have the following setup, which we call the augmented matrix of the system of equations. For the system of equations, \begin{align*} 2x + y &= 5 \\ x - y &= 7 \end{align*} We can write the augmented matrix as shown below. It will contain the coefficients of the system. \begin{bmatrix} 2 & 1 & \left| \right. & 5 \\ 1 & -1 & \left| \right. & 7 \end{bmatrix} The vertical line inside the matrix separates the two sides of the equation. Similar to row additions on equations we discussed above, there are three main types of row operations you can perform on an augmented matrix. Elementary Row Operations and Gaussian Elimination Elementary Row Operations Swap two rows (SR) Multiply a row by a non-zero number (MR) Add a multiple of one row to another row (AR) Notice that doing any of those elementary row operations on a system of equations won't change the final answer. So these operations were chosen with purpose. As shown, we abbreviate the row operations by SR, MR, and AR. Example: Row operations on an augmented matrix \begin{align*} x_1 - 3x_2 + 4x_3 &= -4 \\ 3x_1 - 7x_2 + 7x_3 &= -8 \\ -4x_1 + 6x_2 + 2x_3 &= 4 \\ \end{align*} The augmented matrix is; \begin{bmatrix} 1 & -3 & 4 & \left| \right. &-4 \\ 3 & -7 & 7 & \left| \right. &-8 \\ -4 & 6 & 2 & \left| \right. &4 \\ \end{bmatrix} Now we apply the following row operations successively - aim is to convert the first column to zeros, except in row 1. R_2 \leftarrow R_2 - 3R_1 (AR - to R_2 add -3 times R_1 , and replace R_2 ) R_3 \leftarrow R_3 + 4R_1 (AR - to R_3 add 4 times R_1 , and replace R_3 ) As a result, we get the following matrix, \begin{bmatrix} 1 & -3 & 4 & \left| \right. &-4 \\ 0 & 2 & -5 & \left| \right. &4 \\ 0 & -6 & 18 & \left| \right. &-12 \\ \end{bmatrix} Next, we apply the following row operations successively - the aim is to convert the second column to zeros, except in rows 1 and 2. R_3 \leftarrow R_3 + 3R_2 (AR - to R_3 add 3 times R_2 , and replace R_3 ) We now have the following matrix, \begin{bmatrix} \boldsymbol{1} & -3 & 4 & \left| \right. &-4 \\ 0 & \boldsymbol{2} & -5 & \left| \right. &4 \\ 0 & 0 & \boldsymbol{3} & \left| \right. &0 \\ \end{bmatrix} We have obtained a Row Echelon Form (REF). Let's identify why. 1. Consider all non-zero rows (i.e., rows that are not all zero). 2. The first non-zero element in each non-zero row is called a pivot element (or simply pivot ) - they are in bold. So, pivot columns : Column 1 Column 2 Column 3 Observe that row-wise, the pivot in row 1 is the leftmost, the row 2 pivot is on the right of the row 1 pivot, and finally, the row 3 pivot is on the right of the row 2 pivot. This forms a nice triangular-like arrangement on the matrix. This is called a Row Echelon Form (REF). Note that the columns left to the vertical dashed line of the augmented matrix in REF are all pivot columns. Hence, the system has a unique solution . We can stop here to solve the system of equations by converting back to a system of equations, which we can easily solve. \begin{bmatrix} 1 & -3 & 4 & \left| \right. &-4 \\ 0 & 2 & -5 & \left| \right. &4 \\ 0 & 0 & 3 & \left| \right. &0 \\ \end{bmatrix} \quad \longleftrightarrow \quad \begin{cases} x_1 - 3x_2 + 4x_3 = -4 \\ 2x_2 - 5x_3 = 4 \\ 3x_3 = 0 \end{cases} To solve, we start from the bottom-most equation and work upwards. This is called backward substitution, since the order of substitution is backwards. Equation 3: 3x_3 = 0 \Rightarrow x_3 = 0 Equation 2: 2x_2 - 5 \cdot 0 = 4 \Rightarrow x_2 = 2 Equation 1: x_1 - 3 \cdot 2 + 4\cdot 0 = -4 \Rightarrow x_1 = 2 So we have the following unique solution, \begin{cases} x_1 = 2 \\ x_2 = 2 \\ x_3 = 0 \end{cases} However, we can also proceed further with row operations beyond REF to convert the non-pivot entries in the pivot columns down to zeros, and the pivots to the number 1 . Starting again from the REF we obtained above, \begin{bmatrix} 1 & -3 & 4 & \left| \right. &-4 \\ 0 & 2 & -5 & \left| \right. &4 \\ 0 & 0 & 3 & \left| \right. &0 \\ \end{bmatrix} R_3 \leftarrow \frac{1}{3} R_3 (MR - multiply R_3 by \frac{1}{3} and replace R_3 ) \begin{bmatrix} 1 & -3 & 4 & \left| \right. &-4 \\ 0 & 2 & -5 & \left| \right. &4 \\ 0 & 0 & 1 & \left| \right. &0 \\ \end{bmatrix} R_2 \leftarrow R_2 + 5R_3 (AR - to R_2 add 5 times R_3 , and replace R_2 ) R_1 \leftarrow R_1 - 4R_3 (AR - to R_1 add -4 times R_3 , and replace R_1 ) \begin{bmatrix} 1 & -3 & 0 & \left| \right. & -4 \\ 0 & 2 & 0 & \left| \right. & 4 \\ 0 & 0 & 1 & \left| \right. & 0 \\ \end{bmatrix} R_2 \leftarrow \frac{1}{2} R_2 (MR - multiply R_3 by \frac{1}{2} and replace R_3 ) \begin{bmatrix} 1 & -3 & 0 & \left| \right. & -4 \\ 0 & 1 & 0 & \left| \right. & 2 \\ 0 & 0 & 1 & \left| \right. & 0 \\ \end{bmatrix} R_1 \leftarrow R_1 + 3R_2 (AR - to R_1 add 3 times R_2 , and replace R_1 ) \begin{bmatrix} 1 & 0 & 0 & \left| \right. & 2 \\ 0 & 1 & 0 & \left| \right. & 2 \\ 0 & 0 & 1 & \left| \right. & 0 \\ \end{bmatrix} This is the Reduced Row Echelon Form (RREF) : 1. It is also a Row Echelon Form (REF). 2. The pivot elements are all ones. 3. The only non-zero entry in pivot columns is the pivot element itself. Converting the augmented matrix into a system of equations, we get, \begin{bmatrix} 1 & 0 & 0 & \left| \right. & 2 \\ 0 & 1 & 0 & \left| \right. & 2 \\ 0 & 0 & 1 & \left| \right. & 0 \\ \end{bmatrix} \quad \longleftrightarrow \quad \begin{cases} x_1 + 0x_2 + 0x_3 = 2 \\ 0x_1 + x_2 + 0x_3 = 2 \\ 0x_1 + 0x_2 + x_3 = 0 \end{cases} x_1 + 0x_2 + 0x_3 = 2 \quad \Rightarrow \quad x_1 = 2 0x_1 + x_2 + 0x_3 = 2 \quad \Rightarrow \quad x_2 = 2 0x_1 + 0x_2 + x_3 = 0 \quad \Rightarrow \quad x_3 = 0 We notice that we get the same solutions as with back substitution by on REF, but much more straightforwardly. Either way works. Gaussian Elimination We just performed Gaussian Elimination above. It is a systematic method to simplify a matrix by following a sequence of elementary row operations. The goal is to create as many zeros as possible. This process gave us, A row echelon form (REF) A reduced row echelon form (RREF) Let us go over several examples to identify REFs and RREFs. Example: Determine if the following matrix is in REF or RREF. \begin{bmatrix} -1 & 0 & 3 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{bmatrix} In REF (Row Echelon Form). But not in RREF (Reduced Row Echelon Form), since one of the pivot entries (row 1 pivot) is not a 1 . Example: Determine if the following matrix is in REF or RREF. \begin{bmatrix} 1 & 0 & 0 \\ 0 & 1 & 0 \\ 0 & 0 & 0 \end{bmatrix} It is an RREF (Reduced Row Echelon Form). Since any RREF is also REF, it is also REF. Nature of solutions and REF Example: Note that in this example, the last column (to the right of the vertical line) is a pivot column. \begin{bmatrix} 1 & 2 & 0 & 0 & \left| \right. & 3 \\ 0 & 1 & -2 & -1 & \left| \right. & 0 \\ 0 & 0 & 0 & 0 & \left| \right. & 2 \\ \end{bmatrix} Cannot be solved because the last row will give 0x_1 + 0x_2 + 0x_3 + 0x_4 = 2 \Rightarrow 0 = 2 which is inconsistent. So we come to the following conclusion: In an augmented matrix, if in an REF the last column is a pivot column, the system of equations cannot be solved . This indicates an inconsistent system . Example \begin{bmatrix} 1 & 2 & 0 & 0 & \left| \right. & 3 \\ 0 & 0 & 1 & -2 & \left| \right. & -1 \\ 0 & 0 & 0 & 1 & \left| \right. & 2 \\ \end{bmatrix} The l ast column is a non-pivot column , which means the system is consistent and can be solved. The second column is a non-pivot column , indicating there are infinitely many solutions . Pivot columns to pivot/dependent variables . In this example, columns C_1, C_3, C_4 are pivot columns. So, x_1, x_3, x_4 are dependent variables. Non-pivot columns to free variables. Here, column x_2 is non-pivot. So x_2 is a free/independent variable . The solutions to the dependent variables will be in terms of the free variables. We say that the d ependent variables are parametrized by the free variables . From the matrix, we have the following equations: 1. x_4 = 2 2. x_3 - 2x_4 = -1 \Rightarrow x_3 - 4 = -1 \Rightarrow x_3 = 3 3. x_1 + 2x_2 = 3 \Rightarrow x_1 = -2x_2 + 3 Now we have the solutions as follows, \begin{align*} x_1 &= -2x_2 + 3 \\ x_2 &= x_2 \\ x_3 &= 3 \\ x_4 &= 2 \\ \end{align*} x_2 is a free variable, meaning that any number of x_2 works, but the other (pivot) variable may depend on x_2 . So there are infinitely many solutions. We can plug in any number for x_2 , and it will give a valid solution. For example, 1. If we choose x_2 = 0 we get, \begin{align*} x_1 &= 3 \\ x_2 &= 0 \\ x_3 &= 3 \\ x_4 &= 2 \\ \end{align*} 2. If we choose x_2 = -2 we get, \begin{align*} x_1 &= 7 \\ x_2 &= -2 \\ x_3 &= 3 \\ x_4 &= 2 \\ \end{align*} There are 3 different cases for solutions of systems of equations: 1. Unique solutions: The number of pivot columns equals the total number of columns on the left of the vertical bar | . 2. No solution (Inconsistent): The last column on the right of the vertical bar | is a pivot column. 3. Infinitely many solutions: The number of pivot columns is less than the total number of columns on the left of the vertical bar | , and the last column is non-pivot. We have already seen an example above with a unique solution. Let us look into some examples for the cases too. We'll solve them by Gaussian elimination. Example: Nature of solutions Solve the following system of equations using Gaussian elimination. \begin{align*} x_1 - x_2 + 2x_3 &= 4 \\ 2x_1 + 3x_2 - x_3 &= 1 \\ 7x_1 + 3x_2 + 4x_3 &= 7 \end{align*} The augmented matrix, \begin{bmatrix} 1 & -1 & 2 & | & 4 \\ 2 & 3 & -1 & | & 1 \\ 7 & 3 & 4 & | & 7 \end{bmatrix} Perform the row operations: Let's convert the first column to zeros except for the one in the first row. 1. R_2 \leftarrow R_2 - 2R_1 2. R_3 \leftarrow R_3 - 7R_1 \begin{bmatrix} 1 & -1 & 2 & | & 4 \\ 0 & 5 & -5 & | & -7 \\ 0 & 10 & -10 & | & -21 \end{bmatrix} Let's convert the second column to zeros except for the one in the first and second rows. 3. R_3 \leftarrow R_3 - 2R_2 \begin{bmatrix} \boldsymbol{1} & -1 & 2 & | & 4 \\ 0 & \boldsymbol{5} & -5 & | & -7 \\ 0 & 0 & 0 & | & \boldsymbol{-7} \end{bmatrix} This is in REF. Pivots are in bold. Columns C_1, C_2, C_4 are pivot columns, C_3 is a non-pivot column. Since the last column (which is on the right of the dashed line) is a pivot column, this system has no solutions . To see why, let us write the augmented matrix back as a system of equations. \begin{bmatrix} 1 & -1 & 2 & 4 \\ 0 & 5 & -5 & -7 \\ 0 & 0 & 0 & -7 \\ \end{bmatrix} \quad \longleftrightarrow \quad \begin{cases} x_1 - x_2 + 2x_3 = 4 \\ 5x_2 - 5x_3 = -7 \\ 0 = -7 \end{cases} In the last row, the system of equations is inconsistent , which means there are no solutions. This will always be the case if the column on the right of the dashed line is a pivot column. Example: Nature of solutions Let us solve the following system of equations using Gaussian elimination. \begin{align*} 2x_1 + 3x_2 + x_3 &= 1 \\ x_1 + x_2 + x_3 &= 3 \\ 3x_1 + 4x_2 + 2x_3 &= 4 \end{align*} We can represent this system as an augmented matrix: \begin{bmatrix} 2 & 3 & 1 & | & 1 \\ 1 & 1 & 1 & | & 3 \\ 3 & 4 & 2 & | & 4 \end{bmatrix} Perform row operations to convert the matrix into REF: 1. R_2 \leftarrow R_2 - \frac{1}{2}R_1 2. R_3 \leftarrow R_3 - \frac{3}{2}R_1 \begin{bmatrix} 2 & 3 & 1 & | & 1 \\ 0 & -\frac{1}{2} & \frac{1}{2} & | & \frac{5}{2} \\ 0 & -\frac{1}{2} & \frac{1}{2} & | & \frac{5}{2} \end{bmatrix} 3. R_3 \leftarrow R_3 - R_2 \begin{bmatrix} 2 & 3 & 1 & | & 1 \\ 0 & -\frac{1}{2} & \frac{1}{2} & | & \frac{5}{2} \\ 0 & 0 & 0 & | & 0 \end{bmatrix} The matrix is now in REF . Pivot columns: C_1 and C_2 On the left side matrix, the number of pivot columns is less than the total number of columns . No pivots in the last column . Therefore, there are infinitely many solutions . To find all solutions, we proceed as follows: First, convert all pivots to 1 . 4. R_1 \leftarrow \frac{1}{2} R_1 \quad \quad R_2 \leftarrow (-2) R_2 \begin{bmatrix} 1 & \frac{3}{2} & \frac{1}{2} & | & \frac{1}{2} \\ 0 & 1 & -1 & | & -5 \\ 0 & 0 & 0 & | & 0 \end{bmatrix} Convert the augmented matrix in REF to a system of equations. Since among the columns on the left C_3 is non-pivot. Hence, x_3 is a free variable. We will solve the variables in terms of x_3 . \begin{bmatrix} 1 & \frac{3}{2} & \frac{1}{2} & | & \frac{1}{2} \\ 0 & 1 & -1 & | & -5 \\ 0 & 0 & 0 & | & 0 \end{bmatrix} \quad \longleftrightarrow \quad \begin{cases} x_1 + \frac{3}{2} x_2 + \frac{1}{2} x_3 = \frac{1}{2} \\ x_2 - x_3 = -5 \end{cases} Going along with backsubstitution. We start with the second equation. x_2 = x_3 - 5 Substituting for x_2 in the first equation. x_1 + \frac{3}{2}(x_3 - 5) + \frac{1}{2} x_3 = \frac{1}{2} \Rightarrow x_1 = -2x_3 + 8 The solution is: \begin{cases} x_1 = -2x_3 + 8 \\ x_2 = x_3 - 5 \\ x_3 = x_3 \end{cases} Alternatively, we can continue the elementary row operations beyond the REF to convert all non-zero numbers in pivot columns to zero, except for the pivot itself, and achieve RREF. Start from, \begin{bmatrix} 1 & \frac{3}{2} & \frac{1}{2} & | & \frac{1}{2} \\ 0 & 1 & -1 & | & -5 \\ 0 & 0 & 0 & | & 0 \end{bmatrix} To zero out the non-zeros above pivots, namely the first row entry above the pivot in the second column. 5. R_1 \leftarrow R_1 - \frac{3}{2} R_2 \begin{bmatrix} 1 & 0 & 2 & 8 \\ 0 & 1 & -1 & -5 \\ 0 & 0 & 0 & 0 \end{bmatrix} This is the RREF . From this, we directly have: x_1 + 2x_3 = 8 \quad \Rightarrow \quad x_1 = -2x_3 + 8 x_2 - x_3 = -5 \quad \Rightarrow \quad x_2 = x_3 - 5 Hence, we get the same solutions we saw earlier. There are infinitely many solutions . Exercises Convert each system into an augmented matrix. Then obtain a REF through Gaussian elimination. Based on REF, analyse the nature of its solutions. Solve for the solutions using back substitution, if the system is solvable. Also, proceed to compute the RREF and solve. 1. \begin{align*} 2x_1 + 3x_2 + x_3 + x_4 &= 0 \\ 2x_1 + 2x_2 - x_3 &= 2 \\ 3x_1 + x_2 + x_3 &= 4 \\ 3x_1 + 6x_2 + x_3 &= 5 \\ \end{align*} 2. \begin{align*} x_1 - 2x_2 &= 3 \\ 2x_1 &= 1 \\ 3x_1 + 2x_2 &= 4 \\ 5x_1 + 8x_2 &= 4 \\ \end{align*} 3. \begin{align*} -x_1 + 2x_2 - x_3 &= 2 \\ 2x_1 + 2x_3 &= 4 \\ 3x_1 + 2x_2 + x_3 &= 5 \\ 3x_1 + 8x_2 + 5x_3 &= 5 \\ \end{align*} 4. \begin{align*} x_1 + 2x_2 + 3x_3 + x_4 &= 1 \\ -x_1 + 3x_2 + x_3 + x_4 &= 6 \\ 2x_1 + 4x_2 + 7x_3 &= 4 \\ \end{align*} 5. \begin{align*} x_1 + 3x_2 + 3x_3 + x_4 &= 2 \\ 2x_1 + 3x_2 + x_3 + x_4 &= 8 \\ 3x_1 + 5x_2 + 2x_3 &= 5 \\ \end{align*} 6. \begin{align*} -x_1 - 3x_2 + x_3 &= 1 \\ 2x_1 + x_2 &= 2 \\ 2x_1 + 2x_2 &= 4 \\ 5x_1 - 8x_2 + 2x_3 &= 5 \\ \end{align*}