MatheramaMatherama
← Matrices and Determinants
Matrices and Determinants·Section 1·19 min read

Solving System of Linear Equations

Consider a system of linear equations:

x+2y+z=2(1)x + 2y + z = 2 \tag{1} 2x−3y+z=4(2)2x - 3y + z = 4 \tag{2} 3x+y+2z=3(3)3x + y + 2z = 3 \tag{3}

This system involves three variables: xx, yy, and zz. Our goal is to determine the specific values of xx, yy, and zz that simultaneously satisfy all three equations. These specific values, which make each equation true, are referred to as the solutions of the system of linear equations.

To find these solutions, we employ a systematic method known as eliminating variables. This method simplifies the system step-by-step, allowing us to isolate each variable and solve for its value.

The elimination process works by eliminating any two of the three variables and isolating the remaining variable to determine its value. To achieve this, we follow two simple rules: we can multiply any equation by any non-zero number, and we can add or subtract two equations. This process does not alter the solution of the system of linear equations but helps us in systematically eliminating the unknown variables one by one.

Let us eliminate xx. To eliminate xx, we multiply equation (1)(1) by 2 in our head and subtract it from equation (2)(2):

(2x−3y+z)−2(x+2y+z)=4−2⋅2(2x - 3y + z) - 2(x + 2y + z) = 4 - 2 \cdot 2 2x−3y+z−2x−4y−2z=4−42x - 3y + z - 2x - 4y - 2z = 4 - 4 −7y−z=0(5)-7y - z = 0 \tag{5}

Next, we multiply equation (1)(1) by 3 in our head and subtract it from equation (3)(3):

(3x+y+2z)−3(x+2y+z)=3−3⋅2(3x + y + 2z) - 3(x + 2y + z) = 3 - 3 \cdot 2 3x+y+2z−3x−6y−3z=3−63x + y + 2z - 3x - 6y - 3z = 3 - 6 −5y−z=−3(7)-5y - z = -3 \tag{7}

This gives us two new equations which do not contain xx:

−7y−z=0(5)-7y - z = 0 \tag{5} −5y−z=−3(7)-5y - z = -3 \tag{7}

These two equations can now be used to further isolate and solve for the variables yy and zz.

Now, we substitute y=−32y = -\frac{3}{2} back into equation (5)(5) to solve for zz:

−7(−32)−z=0-7\left(-\frac{3}{2}\right) - z = 0 z=212z = \frac{21}{2}

Next, we substitute y=−32y = -\frac{3}{2} and z=212z = \frac{21}{2} into equation (1)(1) to solve for xx:

x+2(−32)+212=2x + 2\left(-\frac{3}{2}\right) + \frac{21}{2} = 2 x−3+212=2x - 3 + \frac{21}{2} = 2 x=−112x = \frac{-11}{2}

Therefore, the solution to the system of equations is:

x=−112x = -\frac{11}{2} y=−32y = -\frac{3}{2} z=212z = \frac{21}{2}

Gaussian Elimination§

In Gaussian elimination, we represent the system of linear equations in matrix form. This is because, if we observe carefully, the way we solve linear equations involves manipulating the coefficients directly, without needing to repeatedly write the variables xx, yy, zz, or the equals symbol. The Chinese mathematicians were among the first to realize and use this efficient method.

Matrix Representation§

Consider the system of linear equations:

1.x+2y+z=22.2x−3y+z=43.3x+y+2z=3\begin{aligned} 1. & \quad x + 2y + z = 2 \\ 2. & \quad 2x - 3y + z = 4 \\ 3. & \quad 3x + y + 2z = 3 \\ \end{aligned}

We can represent our system of linear equations in an array format, which we call as augmented matrix, as follows:

(121∣22−31∣4312∣3)\begin{pmatrix} 1 & 2 & 1 & | & 2 \\ 2 & -3 & 1 & | & 4 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix}

In this matrix:

  • Each row corresponds to one equation in the system.
  • Each column corresponds to the coefficients of one variable, with the last column representing the constants on the right-hand side of the equations.

For example:

  • The first column contains the coefficients of xx.
  • The second column contains the coefficients of yy.
  • The third column contains the coefficients of zz.
  • The last column contains the constants from the right side of the equations.

R1,R2,R3R_1, R_2, R_3 represent the rows of the matrix, while C1,C2,C3,C4C_1, C_2, C_3, C_4 represent the columns of the matrix.

alt text

Elementary Row Operations§

Based on our observation of solving linear equations, we then define three rules, known as elementary row operations, which help us manipulate the matrix without changing the solutions of the system.

  1. Rule 1: Row Multiplication

    We can multiply any row by any non-zero number. This is equivalent to multiplying all coefficients and the constant term of an equation by that number. This operation does not change the solution of the system.

    For example, multiplying the first row by 2:

    (121∣22−31∣4312∣3)→(242∣42−31∣4312∣3)\begin{pmatrix} 1 & 2 & 1 & | & 2 \\ 2 & -3 & 1 & | & 4 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 2 & 4 & 2 & | & 4 \\ 2 & -3 & 1 & | & 4 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix}

    This is equivalent to multiplying the first equation by 2.

  2. Rule 2: Row Addition/Subtraction

    We can add or subtract the multiples of one row to/from another row. This is equivalent to adding or subtracting the corresponding equations. This operation helps eliminate variables step-by-step.

    For example, subtracting twice the first row from the second row:

    (121∣22−31∣4312∣3)→(121∣20−7−1∣0312∣3)\begin{pmatrix} 1 & 2 & 1 & | & 2 \\ 2 & -3 & 1 & | & 4 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 1 & 2 & 1 & | & 2 \\ 0 & -7 & -1 & | & 0 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix}
  3. Rule 3: Row Swapping

    We can interchange two rows. This is equivalent to swapping the positions of two equations. This does not affect any solutions.

    For example, swapping the first and second rows:

    (121∣22−31∣4312∣3)→(2−31∣4121∣2312∣3)\begin{pmatrix} 1 & 2 & 1 & | & 2 \\ 2 & -3 & 1 & | & 4 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix} \rightarrow \begin{pmatrix} 2 & -3 & 1 & | & 4 \\ 1 & 2 & 1 & | & 2 \\ 3 & 1 & 2 & | & 3 \\ \end{pmatrix}

Applying Row Operations to Matrices§

To solve a system of linear equations using Gaussian elimination, we start by applying row operations to its augmented matrix. Here's a step-by-step explanation:

Step 1: Choosing the Pivot Element

We begin with the top leftmost element of the matrix, which we call the pivot. The pivot is crucial for the elimination process.

  • If all elements in this column are zero, we move diagonally to the next row and column. alt text
  • If the pivot (top leftmost element) is nonzero, we can use it directly. alt text
  • If the pivot is zero, we interchange this row with a row below that has a nonzero element in the first column. This ensures that we have a nonzero pivot to work with. alt text

Step 2: Eliminate Elements Below the Pivot

Once we have a nonzero pivot, the next goal is to make all elements below this pivot zero. This simplifies the system by reducing the number of variables in the subsequent rows.

  • To eliminate the elements below the pivot, we use row operations. Specifically, we multiply the pivot row by a suitable nonzero number and subtract it from the rows below.
  • This step is equivalent to eliminating the variable associated with the pivot from the other equations.

alt text

Step 3: Move to the Next Pivot

After making the elements below the pivot zero, we move diagonally to the element in the second row and second column. This becomes our new pivot.

  • If this new pivot is nonzero, we proceed with the next elimination step.
  • If the new pivot is zero, we interchange this row with a row below that has a nonzero element in the same column. If all elements below are zero as well, we move diagonally to the next row and column.

alt text

Step 4: Repeat the Process

We repeat the process of eliminating elements below the pivot and moving to the next pivot until we reach the last row. By doing this, we systematically transform the matrix into an upper triangular form.

alt text

Let us look at the following example to understand how the Gaussian elimination works.

Row-Echelon Form§

After gaussian elimination in the above example what we have got is called the row echelon form of a matrix

A matrix is in row echelon form if it meets the following criteria:

  1. Leading Element: The first non-zero number from the left (known as the leading element) in each row is to the right of the leading element in the row above it.
  2. Zeros Below Leading Elements: The leading element in each row is the only non-zero entry in its column, with all elements below it being zero.
  3. Non-zero Rows: Any row containing all zeros is at the bottom of the matrix.

From the above example:

(2−31∣4021∣200−1∣−72)\begin{pmatrix} 2 & -3 & 1 & | & 4 \\ 0 & 2 & 1 & | & 2 \\ 0 & 0 & -1 & | & -\frac{7}{2} \end{pmatrix}

Let's analyze why this matrix is in row echelon form:

  1. Leading Element Position:

    • The first row's leading element is 22, which is the first non-zero number from the left.
    • The second row's leading element is 22, positioned to the right of the first row's leading element.
    • The third row's leading element is −1-1, positioned to the right of the second row's leading element.
  2. Zeros Below Leading Elements:

    • In the first column, below the leading element 22 in the first row, all elements are zero.
    • In the second column, below the leading element 22 in the second row, all elements are zero.
    • In the third column, below the leading element −1-1 in the third row, there are no rows left.
  3. Non-zero Rows:

    • There are no rows of all zeros. If there were, they would be at the bottom of the matrix.

Thus, this matrix is in row echelon form because it satisfies all the conditions.

Back Substitution§

After performing Gaussian elimination and getting the row echelon form, we convert the matrix back to equations:

(2−31∣4021∣200−1∣−72)\begin{pmatrix} 2 & -3 & 1 & | & 4 \\ 0 & 2 & 1 & | & 2 \\ 0 & 0 & -1 & | & -\frac{7}{2} \end{pmatrix}

This matrix is in row echelon form. We convert it to the following system of equations:

{2x−3y+z=42y+z=2−1z=−72\begin{cases} 2x - 3y + z = 4 \\ 2y + z = 2 \\ -1z = -\frac{7}{2} \end{cases}

From the last equation, solve for zz:

−1z=−72  ⟹  z=72-1z = -\frac{7}{2} \implies z = \frac{7}{2}

Substitute zz into the second equation to find yy:

2y+72=2  ⟹  2y=2−72  ⟹  2y=−32  ⟹  y=−342y + \frac{7}{2} = 2 \implies 2y = 2 - \frac{7}{2} \implies 2y = -\frac{3}{2} \implies y = -\frac{3}{4}

Substitute yy and zz into the first equation to find xx:

2x−3(−34)+72=4  ⟹  2x+94+72=4  ⟹  2x+234=4  ⟹  2x=4−234  ⟹  2x=−74  ⟹  x=−782x - 3\left(-\frac{3}{4}\right) + \frac{7}{2} = 4 \implies 2x + \frac{9}{4} + \frac{7}{2} = 4 \implies 2x + \frac{23}{4} = 4 \implies 2x = 4 - \frac{23}{4} \implies 2x = -\frac{7}{4} \implies x = -\frac{7}{8}

This process is called back-substitution.

Definition of Rank§

The rank of a matrix is the number of nonzero rows in its row echelon form obtained through Gaussian elimination.

To understand the concept of rank and why it is useful, let's consider a general system of linear equations with mm equations and nn unknowns.

Consider the system of linear equations:

{a11x1+a12x2+⋯+a1nxn=b1a21x1+a22x2+⋯+a2nxn=b2⋮am1x1+am2x2+⋯+amnxn=bm\begin{cases} a_{11}x_1 + a_{12}x_2 + \cdots + a_{1n}x_n = b_1 \\ a_{21}x_1 + a_{22}x_2 + \cdots + a_{2n}x_n = b_2 \\ \vdots \\ a_{m1}x_1 + a_{m2}x_2 + \cdots + a_{mn}x_n = b_m \end{cases}
  1. Coefficient Matrix:

    • The coefficient matrix AA is formed by the coefficients of the unknowns x1,x2,…,xnx_1, x_2, \ldots, x_n in the system.
    A=(a11a12⋯a1na21a22⋯a2n⋮⋮⋱⋮am1am2⋯amn)A = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} \\ a_{21} & a_{22} & \cdots & a_{2n} \\ \vdots & \vdots & \ddots & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} \end{pmatrix}
  2. Augmented Matrix:

    • The augmented matrix [A∣b][A|b] is formed by appending the column of constants b1,b2,…,bmb_1, b_2, \ldots, b_m to the coefficient matrix.
    [A∣b]=(a11a12⋯a1n∣b1a21a22⋯a2n∣b2⋮⋮⋱⋮∣⋮am1am2⋯amn∣bm)[A|b] = \begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} & \vert & b_1 \\ a_{21} & a_{22} & \cdots & a_{2n} & \vert & b_2 \\ \vdots & \vdots & \ddots & \vdots & \vert & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} & \vert & b_m \end{pmatrix}
  3. Gaussian Elimination and Rank:

    • When we apply Gaussian elimination to the augmented matrix [A∣b][A|b], we transform it into its row echelon form.The rank of a matrix is the number of nonzero rows in its row echelon form.
    • If we hide the last column of the augmented matrix during Gaussian elimination, we are effectively applying Gaussian elimination to the coefficient matrix AA.
  4. Simultaneous Echelon Forms:

    • The process of Gaussian elimination can be applied to both AA and [A∣b][A|b] simultaneously, obtaining the echelon forms of both matrices.
  5. Determining the Solution:

    • The relationship between the rank of AA and the rank of [A∣b][A|b] helps determine the type of solution for a system of linear equations:

      1. Unique Solution: If rank(A)=rank([A∣b])=n\text{rank}(A) = \text{rank}([A|b]) = n, then the system has a unique solution.

        Explanation: Here, nn represents the number of unknowns (variables). When the rank of the coefficient matrix AA and the augmented matrix [A∣b][A|b] are equal to nn, it means that there are nn non-zero rows in the row echelon form of the augmented matrix. This implies that we have exactly enough independent equations to solve for all nn variables uniquely without any free variables.

      2. No Solution: If rank(A)≠rank([A∣b])\text{rank}(A) \neq \text{rank}([A|b]), then the system has no solution.

        Explanation: When the rank of the coefficient matrix AA is different from the rank of the augmented matrix [A∣b][A|b], it indicates the presence of a contradiction in the system of equations. This contradiction usually appears as a row in the augmented matrix where all the coefficients of the variables are zero, but the constant term is non-zero (e.g., 0=non-zero number0 = \text{non-zero number}). Such a row represents an inconsistent equation, making it impossible to find any solution.

      3. Infinite Solutions: If rank(A)=rank([A∣b])<n\text{rank}(A) = \text{rank}([A|b]) < n, then the system has infinitely many solutions.

        Explanation: When the rank of the coefficient matrix AA and the augmented matrix [A∣b][A|b] are equal but less than nn, it means that there are fewer independent equations than unknowns. This results in at least one variable being a free variable. In the row echelon form, this scenario is indicated by having one or more rows with all zero coefficients for the variables (but zero as the constant term as well). These free variables can take any value, leading to infinitely many solutions for the system.

      By applying these principles to the system of equations, we can determine the nature of the solutions based on the ranks of the matrices involved.

Gauss-Jordan Elimination Method§

The Gauss-Jordan elimination method is an extension of Gaussian elimination. In this method, we go beyond obtaining a row echelon form by continuing the row operations until the matrix is in reduced row echelon form (RREF). This allows us to read the solution directly from the matrix. Here are the steps involved in the Gauss-Jordan elimination method:

  1. Form the Augmented Matrix:

    Write the system of linear equations as an augmented matrix [A∣b][A|b], where AA is the coefficient matrix and bb is the column of constants.

    (a11a12⋯a1n∣b1a21a22⋯a2n∣b2⋮⋮⋱⋮∣⋮am1am2⋯amn∣bm)\begin{pmatrix} a_{11} & a_{12} & \cdots & a_{1n} & \vert & b_1 \\ a_{21} & a_{22} & \cdots & a_{2n} & \vert & b_2 \\ \vdots & \vdots & \ddots & \vdots & \vert & \vdots \\ a_{m1} & a_{m2} & \cdots & a_{mn} & \vert & b_m \end{pmatrix}
  2. Forward Elimination (Gaussian Elimination):

    Perform Gaussian elimination steps to transform the augmented matrix into row echelon form. In row echelon form:

    • All non-zero rows are above any rows of all zeros.
    • The leading entry (pivot) of each non-zero row is 1.
    • Each leading 1 is to the right of the leading 1 in the previous row.
    • All entries below the leading 1 are zeros.
  3. Normalization and Backward Elimination (Gauss-Jordan Steps):

    After obtaining the row echelon form, continue with the following steps to transform the matrix into reduced row echelon form (RREF):

    • Normalization: Ensure that each leading entry (pivot) in the matrix is 1. If the pivot is not 1, divide the entire row by the value of the pivot to make it 1.

    • Backward Elimination: Make all the entries above each pivot equal to zero by subtracting appropriate multiples of the pivot row from the rows above. This ensures that each leading 1 is the only non-zero entry in its column.

  4. Interpret the Result:

    The resulting matrix in reduced row echelon form will look like this:

    (100⋯0∣d1010⋯0∣d2001⋯0∣d3⋮⋮⋮⋱⋮∣⋮000⋯1∣dn)\begin{pmatrix} 1 & 0 & 0 & \cdots & 0 & \vert & d_1 \\ 0 & 1 & 0 & \cdots & 0 & \vert & d_2 \\ 0 & 0 & 1 & \cdots & 0 & \vert & d_3 \\ \vdots & \vdots & \vdots & \ddots & \vdots & \vert & \vdots \\ 0 & 0 & 0 & \cdots & 1 & \vert & d_n \end{pmatrix}

    If any row in the form 0,0,…,0 ∣ c0, 0, \ldots, 0 \, | \, c (where c≠0c \neq 0) appears, the system has no solution. If there are rows in the form 0,0,…,0 ∣ 00, 0, \ldots, 0 \, | \, 0, the system has infinitely many solutions, and the variables corresponding to these rows are free variables.

Let's solve the following system of linear equations using Gauss-Jordan elimination:

{x+y+z=12x−y+2z=33x+2y−z=4\begin{cases} x + y + z = 1 \\ 2x - y + 2z = 3 \\ 3x + 2y - z = 4 \end{cases}
  1. Form the Augmented Matrix:

    (111∣12−12∣332−1∣4)\begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 2 & -1 & 2 & \vert & 3 \\ 3 & 2 & -1 & \vert & 4 \end{pmatrix}
  2. Forward Elimination (Gaussian Elimination): Perform Gaussian elimination steps to transform the augmented matrix into row echelon form:

    R2←R2−2R1:(111∣10−30∣132−1∣4)R3←R3−3R1:(111∣10−30∣10−1−4∣1)\begin{aligned} R_2 &\leftarrow R_2 - 2R_1: \begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 0 & -3 & 0 & \vert & 1 \\ 3 & 2 & -1 & \vert & 4 \end{pmatrix}\\ R_3 &\leftarrow R_3 - 3R_1: \begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 0 & -3 & 0 & \vert & 1 \\ 0 & -1 & -4 & \vert & 1 \end{pmatrix} \end{aligned}

    Swap the second and third rows to make the leading coefficient of the second row non-zero:

    R2↔R3:(111∣10−1−4∣10−30∣1)R_2 \leftrightarrow R_3: \begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 0 & -1 & -4 & \vert & 1 \\ 0 & -3 & 0 & \vert & 1 \end{pmatrix}

    Subtract 3 times the second row from the third row:

    R3←R3−3R2:(111∣10−1−4∣10012∣−2)R_3 \leftarrow R_3 - 3R_2: \begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 0 & -1 & -4 & \vert & 1 \\ 0 & 0 & 12 & \vert & -2 \end{pmatrix}
  3. Normalization and Backward Elimination (Gauss-Jordan Steps):

    Normalize the third row by dividing by 12:

    R3←112R3  ⟹  (111∣10−1−4∣1001∣−16)R_3 \leftarrow \frac{1}{12}R_3 \implies \begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 0 & -1 & -4 & \vert & 1 \\ 0 & 0 & 1 & \vert & -\frac{1}{6} \end{pmatrix}

    Eliminate the entry above the pivot in the third column in the second row and the first row:

    R2←R2+4R3  ⟹  (111∣10−10∣13001∣−16)R_2 \leftarrow R_2 + 4R_3 \implies \begin{pmatrix} 1 & 1 & 1 & \vert & 1 \\ 0 & -1 & 0 & \vert & \frac{1}{3} \\ 0 & 0 & 1 & \vert & -\frac{1}{6} \end{pmatrix} R1←R1−R3  ⟹  (110∣760−10∣13001∣−16)R_1 \leftarrow R_1 -R_3 \implies \begin{pmatrix} 1 & 1 & 0 & \vert & \frac{7}{6} \\ 0 & -1 & 0 & \vert & \frac{1}{3} \\ 0 & 0 & 1 & \vert & -\frac{1}{6} \end{pmatrix}

    Normalize the second row by dividing by -1:

    R2←−R2  ⟹  (110∣76010∣−13001∣−16)R_2 \leftarrow -R_2 \implies \begin{pmatrix} 1 & 1 & 0 & \vert & \frac{7}{6} \\ 0 & 1 & 0 & \vert & -\frac{1}{3} \\ 0 & 0 & 1 & \vert & -\frac{1}{6} \end{pmatrix}

    Eliminate the entry above the pivot in the second column in the first row:

    R1←R1−R2  ⟹  (100∣32010∣−13001∣−16)R_1 \leftarrow R_1 - R_2 \implies \begin{pmatrix} 1 & 0 & 0 & \vert & \frac{3}{2} \\ 0 & 1 & 0 & \vert & -\frac{1}{3} \\ 0 & 0 & 1 & \vert & -\frac{1}{6} \end{pmatrix}
  4. Interpret the Result:

    The system is now in reduced row echelon form:

    (100∣32010∣−13001∣−16)\begin{pmatrix} 1 & 0 & 0 & \vert & \frac{3}{2} \\ 0 & 1 & 0 & \vert & -\frac{1}{3} \\ 0 & 0 & 1 & \vert & -\frac{1}{6} \end{pmatrix}

    The corresponding solutions are:

    {x=32y=−13z=−16\begin{cases} x = \frac{3}{2} \\ y = -\frac{1}{3} \\ z = -\frac{1}{6} \end{cases}

    Therefore, the solution to the system of equations is:

    x=32,y=−13,z=−16x = \frac{3}{2}, \quad y = -\frac{1}{3}, \quad z = -\frac{1}{6}
Section 1 of 10 · Matrices and Determinants

Mark this section complete when you have worked through its proofs.