# TITLE: Complex Gaussian Elimination v=1.3 # 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 # MAKE: CASIO # MODEL: fx9700Ge or greater # 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 # and enter the number of unknowns at the prompt. # Since you cannot enter complex numbers into a matrix # on the 9700GE 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 # Then enter the following matrix into matrix A # 1 1 1 -1 0 0 # 2 -1 1 3 7 3 # And enter 2 at the prompt. # 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 # # The solutions are displayed in reverse order so the above result # means y=i-1 and x=1+i, similarly if there were three unknowns # the last result would be displayed first. # \i is the complex i # Function memory: f4: Mat C[X,2Y-1] # f5: Mat C[X,2Y] @@ Program 1 Lbl 0 "N"?->A Mat A->Mat C 1->K:Lbl 1 K->J:Lbl 6 J->X:K->Y f4+\if5<>0=>Goto 2 Isz J:J<=A=>Goto 6 Goto 9 Lbl 2 A=1=>Goto 8 Swap C,J,K K+1->J:Lbl 3 J->X:K->Y f4+\if5->Z:K->X Z/(f4+\if5)->M K->P:Lbl 7 J->X:P->Y:f4+\if5->Z:K->X Z-M(f4+\if5) ReP Ans->Mat C[J,2P-1] ImP Ans->Mat C[J,2P] Isz P:P<=A+1=>Goto 7 Isz J:J<=A=>Goto 3 Isz K:KGoto 1 Lbl 8 Mat C_ A->X~Y:f4+\if5->M M=0=>Goto 9 Isz Y (f4+\if5)/M->D[A]_ A=1=>Goto 0 A-1->B:Lbl 4 B+1->C:0->D:Lbl 5 B->X:C->Y D[C](f4+\if5)+D->D Isz C:C<=A=>Goto 5 B->X:A+1->Y f4+\if5-D->Z B->Y:Z/(f4+\if5)->D[B]_ Dsz B:Goto 4 Goto 0 Lbl 9 "NO UNIQUE SOLN" Goto 0