Texas Instruments TI-82

This program inputs the dimensions M and N of a matrix, the exactness R of the calculation, and the matrix [E], and then calculates the reduced row echelon form ("RREF") of [E]. The algorithm used is the standard Gauss Jordan Elimination Algorithm (without pivoting), as described e.g. in O. Bretscher, "Linear Algebra with Applications" (Prentice Hall 1997), p.21.

General: To type an upper case letter, press ALPHA key, followed by the letter. To begin entering the program, press the PGRM key, and select NEW from the menu. The calculator will go into ALPHA mode and prompt you to enter the name. Type in (for example) RREF and press ENTER. The program now displays a colon ":" which must appear at the beginning of each command.
To enter the program commands (all the words in the program that start with a Capital Letter), press PRGM key, then select one of the two menus:

Select the command you need from the appropriate menu. After typing each command, press the ENTER key. (You may also stay on the same line by typing a colon ":", which is ALPHA . ).
To enter or access matrices or matrix operations, press the MATRX key, then select one of the three menus:
We will also need some logical operations within this program. You can access these by pressing the TEST (= 2nd MATH) key, and then selecting one of the menus
Commands:                       Remarks and keying instructions:

:Prompt M,N,R                   Program asks for M, N and R. "Prompt"
                                is 2 on the (PRGM) I/O menu.
:{M,N}->dim[E]                  Defines the dimensions of the matrix we
                                want to row reduce. "{" and "}" are the 
                                2nd( and 2nd) keys; for "->", press 
                                the STO key; "dim" is 3 in the (MATRX) 
                                MATH menu.
:Prompt [E]                     Program asks for the matrix [E] (for
                                instructions how to enter [E] see below!).
:1->I                           Sets I to 1; I will be the current row
                                during row reduction.
:1->J                           J will be the current column.
:While(I<=M and J<=N)           Specifies how long we have to row
                                reduce. "While" is 5 on the (PRGM) 
                                CTL menu. You find "<=" as 6 in the 
                                (TEST) TEST menu and "and" as 1 in the
                                (TEST) LOGIC menu.
:I->K                           Initiates the check if we have to swap
                                the I-th and the K-th column.
:While(K<=M-1 and round([E](K,J),R)=0)
                                Checks if, up to the specified exactness
                                R, the current matrix element is zero.
                                You find "round" as 1 in the (MATH) NUM 
                                menu, and the "=" that we need here as 1
                                in the (TEST) TEST menu.
:K+1->K                         If the matrix element is zero, go down
                                one step in the current column.
:End                            End of last "While" loop; "End" is 7 in 
                                menu (PRGM) CTL.
:If(K=M and round([E](K,J),R)=0)  
                                "If" is 1 in the (PRGM) CTL menu; 
:Goto P                         "Goto" is 0 in the (PRGM) CTL menu.  
                                The last two lines check if we have to 
                                go to the next column to be able to proceed.
:rowSwap([E],I,K)->[E]          Swaps the current row with the first row
                                that does not have a leading zero in the
                                current column; "rowSwap" is 8 in the 
                                (MATRX) MATH menu.
:*row(1/[E](I,J),[E],I)->[E]    Sets the first entry in the current row =1;
                                "*row" is 0 in the (MATRX) MATH menu.
:For(H,1,I-1,1)                 Initiates the first loop: Row reduction 
                                on the rows above the current one. "For" 
                                is 4 in the (PRGM) CTL menu.
:*row+(-[E](H,J),[E],I,H)->[E]  Adds the proper multiple of the I-th row
                                to the H-th row. "*row+" is A in the
                                (MATRX) MATH menu. Careful: "-" is
                                the (-) key here, NOT the - key!!
:0->[E](H,J)                    This matrix element should be zero from
                                the last step; however, due to rounding
                                errors, it often is not.  This step
                                guarantees it, by "brute force".
:End                            Ends the first "For" loop.
:For(H,I+1,M,1)                 Initiates the second loop: Row reduction
                                on the rows below the current one.
:*row+(-[E](H,J),[E],I,H)->[E]  The next steps correspond to the steps
:0->[E](H,J)                    in the first loop.
:End                            Ends the second "For" loop.
:I+1->I                         Go to the next row.
:Lbl P                          This spot in the program is labelled P.
                                "Lbl" is 9 in the (PRGM) CTL menu.
:J+1->J                         Go to the next column.
:End                            Ends the first "While" loop at the 
                                beginning of the program.
:round([E],R)->[E]              Rounds the matrix to the exactness we 
:Disp "RREF",[E]                Output of the row reduced echelon form
                                of our matrix.  "Disp" is 3 in the (PRGM)
                                I/O menu, " is ALPHA +  
Ending: After pressing the ENTER key for the last command, press the QUIT (2nd MODE) key.

Running the program: To run the program, press PRGM, select EXEC, and then RREF, or the name that you choose for this program (it is selected automatically if it is the only program you have.) The screen will display a prompt "prgmRREF". Press ENTER. Enter the M, N, R you want at the question mark (?) prompts. Here, M is the number of rows and N the number of columns that the matrix you want to row reduce has; R specifies the number of decimal places to which your result should be correct, and can be any integer between 1 and 9 (one usually will choose the maximum, R=9; see remarks below!).
Next, the program will ask you for the matrix [E] that you want to row reduce. You can enter [E] either directly, by using the "[" and "]" keys (= 2nd x and 2nd -, respectively) as follows: the input

will enter the matrix
        [ 1  2  3 ]
        [ 4  5  6 ]
Alternatively, you may enter the matrix under some other name in the (MATRX) EDIT menu, say as matrix [A], and then just select (MATRX) NAMES 1 at the "[E]=?" prompt. The latter method is recommended, since otherwise the input-matrix will be "lost" after the program is executed.
In any case, you have to make sure that the dimensions of the matrix you enter coincide with the numbers M of rows and N of columns that you specified at the start of the program! Otherwise, the program will be interrupted and an error message displayed if your matrix is too small, or you will not obtain the reduced row echelon form of the matrix if it is too big.
Pressing ENTER after entering [E] starts the program, which after a little while will return the reduced row echelon form of the matrix, but only display the first columns and rows (of big matrices). If you want to see the other rows and columns, just select (MATRX) NAMES 5, and use the cursor keys to move within the matrix.

Remarks on rounding errors: Unfortunately, the Gauss Jordan Elimination Algorithm is not stable with respect to rounding errors; that means that accumulated rounding errors do not only change the numbers of the output a little, but they can in fact dramatically change the outcome: Instead of e.g. infinitely many solutions (with "free parameters"), you might seemingly obtain a "unique solution"! The boldfaced parts of the program above are included to minimize the effect of these rounding errors, but they cannot completely eliminate them. If you are in doubt that you got the correct type of solution, run the program again, with a smaller value of R. However, for most matrices the maximum value of R=9 will give you the correct outcome.
If you always want to run the program with R=9, delele ",R" from the first line, and add the line ":9->R" as a new second line.
If you want to run the program without these rounding procedures, just delete all boldfaced parts. If you want to have both options, copy the program under another name (like "XREF" or so; please see the Manual Guidebook of your TI-82 on how to copy a program), and just delete all boldfaced parts in the second one.

Check: The 3x6 matrix

          [[ 3    6    9    5   25   53 ]
    [A] =  [ 7   14   21    9   53  105 ]
           [-4   -8  -12    5  -10   11 ]]
will give you (with M=3, N=6, R=9) the result
          [[ 1    2    3    0    5    6 ]
    [E] =  [ 0    0    0    1    2    7 ]
           [ 0    0    0    0    0    0 ]]
which is the exact reduced row echelon form of [A]. However, if you run the modified program without the boldfaced parts, you will get the incorrect result
          [[ 1    2    3    0    0  -37.75 ]
    [E] =  [ 0    0    0    1    0  -10.5  ]
           [ 0    0    0    0    1    8.75 ]]
Note that if this matrix was the augmented matrix of a system of 3 linear equations in 5 variables, the the correct solution will have 3 free parameters, the incorrect one only 2!

Peter Hennes
Math Dept SUNY Stony Brook
July 12 1999