rem system of linear equations solver rem gaussian elimination print "Linear Equations - Gaussian Elimination" print "to solve multiple equations of the form" print "A1*x1+A2*x2+...+An*xn=Constant" print "enter 'q' at any prompt to quit" print dim a(15,16) for j=1 to 15 for i=1 to 16 a(j,i)=0 next i next j input "Number of Equations ";r$ if r$="q" then end r=val(r$) print for j=1 to r print "Equation ";j for i=1 to r+1 if i=r+1 then print "Constant: " else print "Coefficient A(";i;")" end if input " ";a$ if a$="q" then end a(j,i)=val(a$) next i print next j print rem control loop and matrix check for j=1 to r myi=j [loopMyi] i = myi if a(i,j)<>0 goto [calc] myi = myi + 1 if myi <= r then [loopMyi] print "Sorry, no unique solution" end [calc] for k=1 to r+1 x=a(j,k) a(j,k)=a(i,k) a(i,k)=x next k y=1/a(j,j) for k=1 to r+1 a(j,k)=y*a(j,k) next k for i=1 to r if i=j goto [leap] y=-1*a(i,j) for k=1 to r+1 a(i,k)=a(i,k)+y*a(j,k) next k [leap] next i next j print for i=1 to r ans=int(a(i,r+1)*1000+.5)/1000 print "x";i;"= ";ans next i print end