s
:**************************************************************************:** **:** LINEAR EQUATION SOLUTION by GAUSSIAN ELIMINATION **i(:** **2:**************************************************************************<:F: A maximum of 20 equations can be handled by this routineP:bZ:*** DIMENSION MATRIX ***rd A(,)n: :
,
x::*** INPUT NO. of EQUATIONS ***:0 "Number of Equations, N";N : number of coefficientsh "Gaussian Elimination Solution for ";N;"equationsp:NP1 N ::*** READ COEFFICIENTS ***: I N : I = rowf J NP1 : J = coefficient "a(";I;",";J;") = ";: A(I,J) "A(";I;",";J;") = ";A(I,J) J I:": *** PRINT HEADING ***%,:-6:q@ "Solution to set of ";N;" equations by Gaussian elimination."J "Solution to set of ";N;" equations by Gaussian elimination."T:^:*** ELIMINATE COEFFICIENTS BELOW THE DIAGONAL ***h:#r I N6| J I N A(I,I) :Test if pivot element is zero. If so, IM1 I :switch rows M I N A(M,IM1) MM IM1 NP10 A(M,MM),A(IM1,MM)? MMJ M "Coefficient matrix is singular. No unique solution to 1set of equations.": R A(J,I)A(I,I) K I NP1 A(J,K)A(J,K)RA(I,K) A(J,K) % K0 J8 I&: Back substitute by elimination of coefficients0: above diagonal: I NDK N I NR A(K,NP1)A(K,K)X J I Nb L N J >l A(L,NP1)A(L,NP1)RA(L,K)Iv JQ I: Value of variables is column of constants divided by: corresponding number on the diagonal. Compute and: print.) I NAX A(I,NP1)A(I,I)W "X(";I;") = ";Xm "X(";I;") = ";Xu I I N J N SUM A(I,J)X(J) TOTSUM TOT JN "A(";I;","N;")=";TOT J I