RREF.nb Mathematica notebook (current version)
This describes how to use RREF.nb
which contains one Mathematica function called
displayRREF
which displays on the screen all the steps in the forward Gaussian elimination
process and also in the backward phase to produced a reduced row-echelon form when
applied on a matrix \(A\). The matrix can be square or rectangular.
To use, download the RREF.nb
from the link given at the top. Open the notebook using
Mathematica, and evaluate the whole notebook using Evaluation->Evaluate Notebook
.
Now the function displayRREF
is loaded and ready to be used.
Open a new notebook to use the function. Examples of usage are given below.
It has an option to normalize the pivot to 1 or not. Also, it has an option to display each step or just show the final result.
Note that, pivot has to be noramlized to one if we are to obtain an RREF form, since that is the definition of RREF. But this option is there if needed for some other reasons.
There are two functions in the notebook. displayRREF
which does reduced RREF, and
displayREF
which does only the forward Gaussian elimination phase.
Any bugs please let me know.
More examples are shown in the notebook.
Given the matrix \[ \left ( \begin {array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end {array} \right ) \] The RREF is \[ \left ( \begin {array}{ccc} 1 & 0 & -1 \\ 0 & 1 & 2 \\ 0 & 0 & 0 \\ \end {array} \right ) \] To see the steps do
mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} displaymat = True; normalizePivot = True; {result, pivots} = displayRREF[mat, displaymat, normalizePivot]
Note that the default is to display the steps and to also normalized the pivot to one. So the above command can be reduced to
mat = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}} {result, pivots} = displayRREF[mat]
Given the matrix \[ \left ( \begin {array}{cccc} 1 & 2 & 2 & 4 \\ 1 & 3 & 3 & 5 \\ 2 & 6 & 5 & 6 \\ \end {array} \right ) \] The RREF is \[ \left ( \begin {array}{cccc} 1 & 0 & 0 & 2 \\ 0 & 1 & 0 & -3 \\ 0 & 0 & 1 & 4 \\ \end {array} \right ) \] To see the steps do
mat = {{1, 2, 2, 4}, {1, 3, 3, 5}, {2, 6, 5, 6}}; {result, pivots} = displayRREF[mat]
Given the matrix
\[ \left ( \begin {array}{cccc} -7 & -6 & -12 & -33 \\ 5 & 5 & 7 & 24 \\ 1 & 0 & 4 & 5 \\ \end {array} \right ) \]
The RREF is
\[ \left ( \begin {array}{cccc} 1 & 0 & 0 & -3 \\ 0 & 1 & 0 & 5 \\ 0 & 0 & 1 & 2 \\ \end {array} \right ) \]
To see the steps do
mat = {{-7, -6, -12, -33}, {5, 5, 7, 24}, {1, 0, 4, 5}}; displaymat = True; normalizePivot = True; {result, pivots} = displayRREF[mat, displaymat, normalizePivot]
Given \(A\) as \[ \left ( \begin {array}{ccccc} s & \sqrt {s} & 3 & 10 & s^2 \\ 1 & s & 2 s & 10 & 1 \\ 0 & 2 & 3 & 10 & s^9 \\ \frac {1}{s} & 5 & 3 & 8 & s+2 \\ \end {array} \right ) \]
The RREF is
\[ \left ( \begin {array}{ccccc} 1 & 0 & 0 & 0 & \frac {s \left (8 s^{21/2}-15 s^{19/2}-10 s^{5/2}-5 s^{3/2}-47 s^{10}+75 s^9+31 s^3-25 s^2+10 s+33 \sqrt {s}-66\right )}{-7 s^{3/2}+31 s^3-45 s^2+14 s+15 \sqrt {s}-30} \\ 0 & 1 & 0 & 0 & -\frac {s^2 \left (8 s^{10}-15 s^9-7 s^8+15 s^7-10 s^2+2 s+18\right )}{-7 s^{3/2}+31 s^3-45 s^2+14 s+15 \sqrt {s}-30} \\ 0 & 0 & 1 & 0 & \frac {-4 s^{21/2}+5 s^{19/2}+5 s^{5/2}+10 s^{3/2}+4 s^{12}-25 s^{11}+20 s^{10}-5 s^4-12 s^3+17 s^2-20 s-5 \sqrt {s}+10}{-7 s^{3/2}+31 s^3-45 s^2+14 s+15 \sqrt {s}-30} \\ 0 & 0 & 0 & 1 & \frac {-s^{21/2}+3 s^{5/2}+6 s^{3/2}-7 s^{12}+12 s^{10}+s^4-8 s^3+3 s^2-12 s-3 \sqrt {s}+6}{14 s^{3/2}-62 s^3+90 s^2-28 s-30 \sqrt {s}+60} \\ \end {array} \right ) \]
To see the steps do
mat = {{s, Sqrt[s], 3, 10, s^2}, {1, s, 2*s, 10, 1}, {0, 2, 3, 10, s^9}, {1/s, 5, 3, 8, 2 + s}}; displaymat = True; normalizePivot = True; {result, pivots} = displayRREF[mat, displaymat, normalizePivot]