# TITLE: Gaussian Elimination v1.3 # AUTHOR: Roy F.A. Maclean # based on the algorithm in Adv.Eng.Maths. (7th ed) by E.Kreyzig # EMAIL: rfamgm at gmail # WEB: http://www.spiderpixel.co.uk/caspro # DATE: 3Apr1996, 16Feb1997, 27Feb1999 # MAKE: CASIO # MODEL: 7700GE or greater # NOTES: This program is used to solve a # system of n linear equations in n unknowns. # Put the augmented NxN+1 matrix into matrix A. # and dimension matrix B to be a row with N columns. # Then run the program and enter the number # of unknowns N at the prompt. # The program will say which row operations it uses # and display the matrix at each stage. # Finally it will display the soln. # # e.g. to solve: # x + y+ z =12 # 2x+2y+ z =18 # x -3y+2z =-2 # Put the following matrix into matrix A # 1 1 1 12 # 2 2 1 18 # 1 -3 2 -2 # and set up matrix B to be 1x3 # Then run the program and enter 3 at the prompt. # Various messages will appear to say which rows # it adds to which other rows and which ones it is swapping. # Then it displays the matrix: # [ 1 5 6 ] # which means that the soln is x=1, y=5, z=6 # # % represents the fraction symbol @@ Program 1 Lbl 0 "N"?->A "INITIAL MATRIX"_ Mat A->Mat C_ 1->K:Lbl 1 K->J:Lbl 6 Mat C[J,K]<>0=>Goto 2 Isz J:J<=A=>Goto 6 Goto 9 Lbl 2 A=1=>Goto 8 J=K=>Goto A "SWAPPING ROWS" K_ "AND" J_ Swap C,J,K Mat C_ Lbl A K+1->J:Lbl 3 -Mat C[J,K]%Mat C[K,K]->H H=0=>Goto B "ADDING" H_ "TIMES ROW" K_ "TO ROW" J_ *Row+ H,C,K,J Mat C_ Lbl B Isz J:J<=A=>Goto 3 Isz K:KGoto 1 Lbl 8 "ELIMINATION COMPLETE"_ Mat C_ Mat C[A,A]->M M=0=>Goto 9 Mat C[A,A+1]%M->Mat B[1,A] A=1=>Goto 7 A-1->B:Lbl 4 B+1->C:0->D:Lbl 5 Mat B[1,C]Mat C[B,C]+D->D Isz C:C<=A=>Goto 5 (Mat C[B,A+1]-D)%Mat C[B,B]->Mat B[1,B] Dsz B:Goto 4 Lbl 7 "THE SOLN IS"_ Mat B_ Goto 0 Lbl 9 "NO UNIQUE SOLN" Goto 0