Loading [MathJax]/extensions/TeX/boldsymbol.js
Skip to main content
Library homepage
 

Text Color

Text Size

 

Margin Size

 

Font Type

Enable Dyslexic Font
Mathematics LibreTexts

10.3: Basic Gauss Jordan

( \newcommand{\kernel}{\mathrm{null}\,}\)

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

#  Load Useful Python Libraries
import numpy as np
import sympy as sym
sym.init_printing(use_unicode=True)
#  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:

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

# Put your answer here.
# 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:

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

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

Login with LibreOne to run this code cell interactively.

If you have already signed in, please refresh the page.

answer_from_video = [[1, 0, 0, -1], [0, 1, 0, 1], [0, 0, 1, 2]]
np.allclose(answer, answer_from_video)
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.

Support Center

How can we help?