ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

55 lines
1.3 KiB

  1. 10 PRINT "SIMULTANEOUS EQUATIONS"
  2. 20 PRINT
  3. 29 REM - LIMIT A() TO A(R,R+1) WHERE R=MAX NO. OF EQUATIONS
  4. 30 DIM A(9,10)
  5. 40 PRINT "NUMBER OF EQUATIONS";
  6. 50 INPUT R
  7. 60 PRINT "COEFFICIENT MATRIX:"
  8. 70 FOR J=1 TO R
  9. 80 PRINT "EQUATION";J
  10. 90 FOR I=1 TO R+1
  11. 100 IF I=R+1 THEN 130
  12. 110 PRINT " COEFFICIENT";I;
  13. 120 GOTO 140
  14. 130 PRINT " CONSTANT";
  15. 140 INPUT A(J,I)
  16. 150 NEXT I
  17. 160 NEXT J
  18. 170 FOR J=1 TO R
  19. 178 REM - STATEMENT 180 TO 220 FIND THE FIRST EQUATION WITH A
  20. 179 REM - NON-ZERO COEFFICIENT FOR THE CURRENT COLUMN
  21. 180 FOR I=J TO R
  22. 190 IF A(I,J)<>0 THEN 230
  23. 200 NEXT I
  24. 210 PRINT "NO UNIQUE SOLUTION"
  25. 220 GOTO 440
  26. 229 REM - STATEMENTS 230 TO 270 MOVE THAT EQUATION UP TO THE CURRENT ROW
  27. 230 FOR K=1 TO R+1
  28. 240 X=A(J,K)
  29. 250 A(J,K)=A(I,K)
  30. 260 A(I,K)=X
  31. 270 NEXT K
  32. 278 REM - REM - STATEMENTS 280 TO 310 GET A 1 COEFFICIENT IN THE FIRST
  33. 279 REM - NON-ZERO COLUMN OF THE CURRENT ROW
  34. 280 Y=1/A(J,J)
  35. 290 FOR K=1 TO R+1
  36. 300 A(J,K)=Y*A(J,K)
  37. 310 NEXT K
  38. 318 REM - STATEMENTS 320 TO 380 SUBTRACT THE CURRENT EQUATION FROM
  39. 319 REM - THE OTHER ROWS
  40. 320 FOR I=1 TO R
  41. 330 IF I=J THEN 380
  42. 340 Y=-A(I,J)
  43. 350 FOR K=1 TO R+1
  44. 360 A(I,K)=A(I,K)+Y*A(J,K)
  45. 370 NEXT K
  46. 380 NEXT I
  47. 389 REM - THIS PROCESS IS REPEATED FOR ALL EQUATIONS
  48. 390 NEXT J
  49. 400 PRINT
  50. 409 REM - PRINT SOLUTIONS
  51. 410 FOR I=1 TO R
  52. 420 PRINT "x";I;"=";INT(A(I,R+1)*1000+.5)/1000
  53. 430 NEXT I
  54. 440 END