# The function memory will need to be typed in manually. # TITLE: Complex Gaussian Elimination v1.5:9x50 # AUTHOR: Roy F.A. Maclean # a complex adaption of the real version # which was 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: 2Apr1996, 28Sep1999, 22Dec2002 # MAKE: CASIO # MODEL: 9850 # # NOTES: This uses gaussian elimination to solve # a set of n linear equations in n unknowns # when the solutions may be complex. # You must enter the augmented matrix into matrix A # # Since you cannot enter complex numbers into a matrix # on the 9850 then this program expects every odd # column to be a real part entry and every even column # to the right of this to be the imaginary part. # If the number of unknowns is 'n' then you should set # matrix A to have n rows and 2n+2 columns. # # e.g. to solve # (1+i)x + (1-i)y = 0+0i # (2-i)x +(1+3i)y =7+3i # set up matrix A as 2x6 with the following entries # 1 1 1 -1 0 0 # 2 -1 1 3 7 3 # # Then run the program and the reduced upper triangular # matrix will be displayed: # 1 1 1 -1 0 0 # 0 0 2 5 7 3 # And then the solutions: # 1+i # 1-i # # Example of 3 unknowns: # # (1+i)x + (1-i)y +z = 0 # (2-i)x +(1+3i)y +z = 9+4i # x + y +z = 4+i # # So set up matrix A as a 3x8 matrix and use the following: # # 1 1 1 -1 1 0 2 1 # 2 -1 1 3 1 0 9 4 # 1 0 1 0 1 0 4 1 # # It will display the solutions: # 1+i # 1-i # 2+i # # \i is the complex i # * is the multiplication symbol which can be omitted # _ represents the display symbol: shift|vars|f5 # # On models with autodimensioning capability # such as 9850GB+ and 9970G then you can replace the line: # Seq(0,X,1,2A+2,1->List 1 # with the line: # 2A+2->Dim List 1 # # # Notes for programmers: # # Although you might think single row input matrix making A=1 # would cause errors with nested 'For' loops it doesn't because although # the first 'For' loop exits out at the wrong 'Next' command from the # point of view of the way 'For' loops ought to work, it never sees # the correct 'Next' because of the A=1=>Goto 8, and so never # causes an error. So in this case two wrongs make a right. # # # Function memory: # # Also as part of the program the following two expressions need to be stored in function memories: # # The f-mem menu is on [Optn][F6][F6][F3] # # f4: Mat C[X,2Y-1]+\i*Mat C[X,2Y] # f5: List 1[2C-1]+\i*List 1[2C] @@ Program "CXGAUSLM" Lbl 0 Dim Mat A List Ans[1->A List Ans[2->B B<>2A+2=>"MATRIX IS NOT IN AUGMENTED FORM" B<>2A+2=>Goto 0 Seq(0,X,1,2A+2,1->List 1 "INITIAL MATRIX"_ Mat A->Mat C_ For 1->K To A-1 For K->J To A J->X:K->Y:f4<>0=>Break Next A=1=>1->J:A=1=>1->X f4=0=>Goto 9 A=1=>Goto 8 If J<>K Then ClrText "SWAPPING ROWS"_ Swap C,J,K Mat C_ IfEnd For K+1->J To A J->X:K->Y f4->Z:K->X Z/f4->M For K->P To A+1 J->X:P->Y:f4->Z:K->X Z-Mf4 ReP Ans->Mat C[J,2P-1 ImP Ans->Mat C[J,2P Next Next Next Lbl 8 "ELIMINATION COMPLETE"_ Mat C_ A->X~Y:f4->M M=0=>Goto 9 Isz Y "THE SOLN IS"_ f4/M ReP Ans->List 1[2A-1 ImP Ans->List 1[2A A=1=>Goto 0 For A-1->E To 1 Step -1 0->D For E+1->C To A E->X:C->Y f5*f4+D->D Next E->X:A+1->Y f4-D->Z E->Y:Z/f4 ReP Ans->List 1[2E-1] ImP Ans->List 1[2E] Next For 1->C To A f5_ Next Goto 0 Lbl 9 "NO UNIQUE SOLN" Goto 0