|
- 10 PRINT "SIMULTANEOUS EQUATIONS"
- 20 PRINT
- 29 REM - LIMIT A() TO A(R,R+1) WHERE R=MAX NO. OF EQUATIONS
- 30 DIM A(9,10)
- 40 PRINT "NUMBER OF EQUATIONS";
- 50 INPUT R
- 60 PRINT "COEFFICIENT MATRIX:"
- 70 FOR J=1 TO R
- 80 PRINT "EQUATION";J
- 90 FOR I=1 TO R+1
- 100 IF I=R+1 THEN 130
- 110 PRINT " COEFFICIENT";I;
- 120 GOTO 140
- 130 PRINT " CONSTANT";
- 140 INPUT A(J,I)
- 150 NEXT I
- 160 NEXT J
- 170 FOR J=1 TO R
- 178 REM - STATEMENT 180 TO 220 FIND THE FIRST EQUATION WITH A
- 179 REM - NON-ZERO COEFFICIENT FOR THE CURRENT COLUMN
- 180 FOR I=J TO R
- 190 IF A(I,J)<>0 THEN 230
- 200 NEXT I
- 210 PRINT "NO UNIQUE SOLUTION"
- 220 GOTO 440
- 229 REM - STATEMENTS 230 TO 270 MOVE THAT EQUATION UP TO THE CURRENT ROW
- 230 FOR K=1 TO R+1
- 240 X=A(J,K)
- 250 A(J,K)=A(I,K)
- 260 A(I,K)=X
- 270 NEXT K
- 278 REM - REM - STATEMENTS 280 TO 310 GET A 1 COEFFICIENT IN THE FIRST
- 279 REM - NON-ZERO COLUMN OF THE CURRENT ROW
- 280 Y=1/A(J,J)
- 290 FOR K=1 TO R+1
- 300 A(J,K)=Y*A(J,K)
- 310 NEXT K
- 318 REM - STATEMENTS 320 TO 380 SUBTRACT THE CURRENT EQUATION FROM
- 319 REM - THE OTHER ROWS
- 320 FOR I=1 TO R
- 330 IF I=J THEN 380
- 340 Y=-A(I,J)
- 350 FOR K=1 TO R+1
- 360 A(I,K)=A(I,K)+Y*A(J,K)
- 370 NEXT K
- 380 NEXT I
- 389 REM - THIS PROCESS IS REPEATED FOR ALL EQUATIONS
- 390 NEXT J
- 400 PRINT
- 409 REM - PRINT SOLUTIONS
- 410 FOR I=1 TO R
- 420 PRINT "x";I;"=";INT(A(I,R+1)*1000+.5)/1000
- 430 NEXT I
- 440 END
|