A Gauss-Jordan elimination demonstrator. ----begin documentation---- This 82u-file was prepared by Mikael Bonnier, http://www.df.lth.se.orbin.se/~mikaelb/. ****************************** * GAUSSIAN.82G for the TI-82 * ****************************** ACKNOWLEDGMENT GAUSSIAN.82G is a group file containing the programs GAUSSIAN.82P, GAUSSNEW.82P, and GAUSSCLN.82P. These programs were written by John Powers of the TI Graphics Team and are released to the public domain. You may copy and change these programs. INTRODUCTION This program demonstrates the Gauss-Jordan elimination technique to solve a system of equations. The action taken and the resulting matrix is displayed after each step. The SWAP step lists the numbers of the rows swapped and the result of the matrix after the rows are swapped. The DIVIDE step displays which row is being divided through by the pivot. Subsequent SUBTRACT steps indicate which row is being reduced by subtracting a multiple of the pivot row. HOW TO USE GAUSSIAN This program reduces matrix [A] in place. Formulate a system of simultaneous linear equations as an Nx(N+1) matrix in variable [A]. Run GAUSSIAN to watch step-by-step Gauss-Jordan elimination. Example: [[ 0 2 3 7] [-5 3 7 -3] -> [A] [ 3 -8 2 6] prgmGAUSSIAN [ENTER] SWAP {1 2} Swap rows 1 and 2 [[-5 3 7 -3] [0 2 3 7 ] [3 -8 2 6 ]] DIVIDE Divide row 1 through by -5 1 [[1 -3/5 -7/5 3... [0 2 3 7... [3 -8 2 6... SUBTRACT Multiply row 1 by 0 and 2 subtract from row 2 [[1 -3/5 -7/5 3... [0 2 3 7... [3 -8 2 6... SUBTRACT Multiply row 1 by 3 and 3 subtract from row 3 [[1 -3/5 -7/5 ... [0 2 3 ... [0 -31/5 31/5 ... SWAP Swap rows 2 and 3 {2 3} [[1 -3/5 -7/5 ... [0 -31/5 31/5 ... [0 2 3 ... DIVIDE Divide row 2 by -31/5 2 [[1 -3/5 -7/5 3... 0 1 -1 -... 0 2 3 7... SUBTRACT Multiply row 2 by -3/5 and 1 subtract from row 1 [[1 0 -2 6/31 ... [0 1 -1 -21/31... [0 2 3 7 ... SUBTRACT Multiply row 2 by 2 and 3 subtract from row 3 [[1 0 -2 6/31 ... [0 1 -1 -21/31... [0 0 5 259/31... DIVIDE Divide row 3 by 5 3 [[1 0 -2 6/31 ... [0 1 -1 -21/31... [0 0 1 259/15... SUBTRACT Multiply row 3 by -2 and 1 subtract from row 1 [[1 0 0 548/15... [0 1 -1 -21/31... [0 0 1 259/15... SUBTRACT Multiply row 3 by -1 and 2 subtract from row 2 [[1 0 0 548/155... [0 1 0 154/155... [0 0 1 259/155... Press right arrow [->] to see the ...1 0 0 548/155] right column of the matrix ...0 1 0 154/155] ...0 0 1 250/155]] Done Answer, x=548/155, y=154/155, and z=259/155. The program pauses after each step to allow the user to scroll the resulting matrix. Press [ENTER] to continue with the next step. Program GAUSSNEW generates a new matrix in variable [A]. It prompts for the number of matrix rows. Type prgmGAUSSNEW prgmGAUSSIAN to generate a new random matrix, display it, then begin the elimination process. Auxiliary routine GAUSSCLN cleans up matrix entries which are close to zero. ----begin ascii---- \START82\ \COMMENT=Program file dated 08/13/96, 16:57 \NAME=GAUSSCLN \FILE=GAUSSCLN.82P :For(S,1,M) :For(T,1,N) :If abs [A](S,T)\<=\1\E\\(-)\10 :0\->\[A](S,T) :End :End \STOP82\ \START82\ \COMMENT=Program file dated 08/13/96, 16:57 \NAME=GAUSSIAN \FILE=GAUSSIAN.82P :dim [A]\->\\L6\ :\L6\(1)\->\M :\L6\(2)\->\N :For(R,1,M) :0\->\P :0\->\J :For(I,R,M) :abs [A](I,R)\->\Q :If Q>P:Then :Q\->\P :I\->\J :End :End :If J=0:Goto 0 :If J\<>\R:Then :Disp "SWAP",{R,J} :rowSwap([A],R,J)\->\[A] :Pause [A]\>Frac\ :End :Disp "DIVIDE",R :*row([A](R,R)\^-1\,[A],R)\->\[A] :prgmGAUSSCLN :Pause [A]\>Frac\ :For(I,1,M) :If I\<>\R:Then :Disp "SUBTRACT",I :*row+(\(-)\[A](I,R),[A],R,I)\->\[A] :prgmGAUSSCLN :Pause [A]\>Frac\ :End :End :End :Return :Lbl 0 :Disp "[A] ILL-CONDITIONED" \STOP82\ \START82\ \COMMENT=Program file dated 08/13/96, 16:57 \NAME=GAUSSNEW \FILE=GAUSSNEW.82P :Prompt N :augment(randM(N,N),randM(N,1))\->\[B] :[B]\->\[A] \STOP82\ ----begin uue---- begin 644 GAUSSIAN.82G M*BI423@R*BH:"@!'*E-50E1204-4*BM)/QBP7``022M2$2M<`"M2*TD1!%P`/U]'0553 M4T-,3C_87``#/]0_U#_4/]4_UC`_WBI<`"E)3$QQ0T].1$E424].140J"P`; I``5'05534TY%5QL`&0#=3C\4($XK3A$K($XK,1$1!%P!/UP!!%P`>V8` ` end ----end uue----