Skip to main content
Mathematics LibreTexts

10.3: Basic Gauss Jordan

  • Page ID
    65065
  • \( \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}}\)

    \( \newcommand{\vectorA}[1]{\vec{#1}}      % arrow\)

    \( \newcommand{\vectorAt}[1]{\vec{\text{#1}}}      % arrow\)

    \( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vectorC}[1]{\textbf{#1}} \)

    \( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)

    \( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)

    \( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)

    \( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)

    \( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)

    #  Load Useful Python Libraries
    import numpy as np
    import sympy as sym
    sym.init_printing(use_unicode=True)

    The following is implementation of the Basic Gauss-Jordan Elimination Algorithm for Matrix \(A^{m \times n}\) (Pseudocode):

    for i from 1 to m:
        for j from 1 to m    
            if i ≠ j:
                Ratio = A[j,i]/A[i,i]
                #Elementary Row Operation 3
                for k from 1 to n:
                    A[j,k] = A[j,k] - Ratio * A[i,k]
                next k
            endif
        next j
        
        #Elementary Row Operation 2
        Const = A[i,i]
        for k from 1 to n:
            A[i,k] = A[i,k]/Const
    next i
    
    Do This

    using the Pseudocode provided above, write a basic_gauss_jordan function which takes a list of lists \(A\) as input and returns the modified list of lists:

    # Put your answer here.

    Lets check your function by applying the basic_gauss_jordan function and check to see if it matches the answer from matrix \(A\) in the pre-class video:

    A = [[1, 1, 1, 2], [2, 3, 1, 3], [0, -2, -3, -8]]
    answer = basic_gauss_jordan(A)
    sym.Matrix(answer)
    answer_from_video = [[1, 0, 0, -1], [0, 1, 0, 1], [0, 0, 1, 2]]
    np.allclose(answer, answer_from_video)

    The above psuedocode does not quite work properly for all matrices. For example, consider the following augmented matrix:

    \[\begin{split}
    B = \left[
    \begin{matrix}
    0 & 1 & 33\\
    5 & 3 & 7 \\
    6 & 69 & 4
    \end{matrix}
    \, \middle\vert \,
    \begin{matrix}
    30 \\
    90 \\
    420
    \end{matrix}
    \right]
    \end{split} \nonumber \]

    Question

    Explain why doesn’t the provided basic_gauss_jordan function work on the matrix \(B\)?

    Question

    Describe how you could modify matrix \(B\) so that it would work with basic_gauss_jordan AND still give the correct solution?


    This page titled 10.3: Basic Gauss Jordan is shared under a CC BY-NC 4.0 license and was authored, remixed, and/or curated by Dirk Colbry via source content that was edited to the style and standards of the LibreTexts platform; a detailed edit history is available upon request.