Skip to main content
Engineering LibreTexts

2.5: Systems of Equations

  • Page ID
    14919
  • \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \) \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\) \(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)\(\newcommand{\AA}{\unicode[.8,0]{x212B}}\)

    We can use matrices to solve systems of linear equations. Here it is a good idea to read up a bit on some matrix algebra.
    Suppose we have the following system of equations:

    \[\begin{Bmatrix} 3x+2y-z = 10\\ -x+3y+2z = 5\\ x-y-z = -1 \end{Bmatrix}\nonumber\]

    We will solve this system, i.e. find the values of the variables that satisfy all of the equations simultaneously, in three ways: using reduced row echelon form, using matrix inverses, and using “left division.”

    Method 1: Reduced Row Echelon Form

    Here we create the “augmented matrix” of the coefficients of the variables with the constants to the right of the equals signs.
    >> AugmentedMatrix = [3 2 -1 10;-1 3 2 5;1 -1 -1 -1];
    >> rref(AugmentedMatrix)

    ans =
    1 0 0 -2
    0 1 0 5
    0 0 1 -6

    This tells us that there is only one way to solve this system, i.e. only one solution, namely x = -2, y = 5, z = -6. You can check that is correct by substituting these values back into the system of equations:

    \[\begin{Bmatrix} 3(−2) + 2(5) − (−6) = 10\\
    −(−2) + 3(5) + 2(−6) = 5\\
    (−2) − (5) − (−6) = −1 \end{Bmatrix}\nonumber\]

    and verifying that they are all correct.

    Method 2: Using the matrix inverse

    Here we create two matrices, one for the coefficients of the variables and one for the constants to the right of the equals signs. Note that we can define these on the same line to save space:

    >> Coeffs = [3 2 -1;-1 3 2;1 -1 -1]; Constants=[10; 5; -1];

    Since the determinant of Coeffs is non-zero (check!) we can solve the system with the inverse:

    >> inv(Coeffs)*Constants

    ans =
    -2
    5
    -6

    This also tells us that the only solution is x = -2, y = 5, z = -6.

    Method 3: Using left division

    The motivation for this method is complicated. We suggest that you read the Matlab documentation on left (and right) division of matrices. Again we create the two matrices, Coeffs and Constants

    >> Coeffs = [3 2 -1;-1 3 2;1 -1 -1]; Constants=[10; 5; -1];

    and use the backslash (be careful to use the correct slash):

    >> Coeffs\Constants

    ans =
    -2
    5
    -6

    This also tells us that the only solution is x = -2, y = 5, z = -6.


    This page titled 2.5: Systems of Equations is shared under a CC BY-NC 3.0 license and was authored, remixed, and/or curated by Troy Siemers (APEX Calculus) via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.