rem system of linear equations solver rem compact crout print "Linear Equations - Compact Crout" print "to solve multiple symmetric equations of the form" print "A1*x1+A2*x2+...+An*xn=B" print "data is input by columns using the upper triangle of matrix A" print "enter 'q' at any prompt to quit" dim a(120) dim b(15) e5=.00000001 gosub [inputA] gosub [factorA] print print "Determinant of A" print print "Det = ";d8 print [again] rem read vector B gosub [inputB] rem solution of A*X=B gosub [getX] rem output vector X gosub [outputX] print print "Do you want to input another vector B (y/n)? "; input " ";w$ if w$="n" or w$="q" then end goto [again] [getX] rem forward solution j0=1 rem loop over j columns for j=2 to n j2=j-1 rem reduce component b(j) for k=1 to j2 j4=j0+k b(j)=b(j)-a(j4)*b(k) next k j0=j0+k next j rem back substitution j0=0 rem perform b(j)/a(j,j) for j=1 to n j0=j0+j b(j)=b(j)/a(j0) next j rem backward loop over j columns j=n j0=n*(n+1)/2 [djump] if (j<=1) goto [cjump] j2=j-1 rem subtract columns j0=j0-j for i=1 to j2 i1=j0+i b(i)=b(i)-a(i1)*b(j) next i j=j2 goto [djump] [cjump] return [factorA] j0=1 rem check for zero pivot d8=a(j0) if abs(d8)