Post Reply 
(71B: Math ROM): Linear System Solver & Polynomial Solver
09-13-2022, 07:05 PM
Post: #1
(71B: Math ROM): Linear System Solver & Polynomial Solver
Thank you Bob for the Math ROM!

Linear System Solver

LINSOLV - 195 bytes
Math Rom Required

Solves Ax = b

Code:
95 OPTION BASE 1

100 DESTROY A,B,X,N,I
105 DISP "LINEAR SYSTEM" @ WAIT .5
110 INPUT "SIZE? "; N
115 DIM A(A,N),B(N),X(N)
120 DISP "COEFFS: " @ WAIT .5
125 MAT INPUT A
130 DISP "B(I):" @ WAIT .5
135 MAT INPUT B
140 MAT X=SYS(A,B)

200 FOR I=1 TO N
205 DISP "X"&STR$(I)&")= "&STR$(X(I))
210 PAUSE
220 NEXT I

Note: DIM var(n) makes a column matrix n x 1

Polynomial Roots

POLYROOT - 373 bytes
Math Rom Required

Solves p(x) = 0
P = coefficients
R = solutions
Order of descending order
Displays real and complex roots.

Code:
100 DESTROY R,P,I,N,U @ OPTION BASE 1
105 DISP "P(X)=0" @ WAIT .5
106 DISP "P(X): REALS ONLY" @ WAIT .5
107 DISP "ROOTS CAN BE COMPLEX"
110 INPUT "ORDER? ";N
115 DIM P(N+1) @ COMPLEX R(N+1)

200 FOR I=1 TO N+1
205 DISP "X^"&STR$(N+1-I) @ WAIT .5
210 INPUT "COEFF? "; P(I)
215 NEXT I

295 DISP "CALC..."
300 MAT R=PROOT(P)
310 FOR I=1 TO N
315 DISP "REAL"&STR$(I)&"= "&STR$(REPT(R(I))) @ PAUSE
320 IF IMPT(R(I))=0 THEN 330
325 DISP "IMAG"&STR$(I)&"= "&STR$(IMPT(R(I))) @ PAUSE
330 NEXT I

400 U$=KEY$ @ INPUT "AGAIN? (Y/N)"; U$
405 IF UPRC$(U$)="Y" THEN 110
Visit this user's website Find all posts by this user
Quote this message in a reply
09-14-2022, 12:18 PM
Post: #2
RE: (71B: Math ROM): Linear System Solver & Polynomial Solver
(09-13-2022 07:05 PM)Eddie W. Shore Wrote:  Thank you Bob for the Math ROM!

You're welcome Eddie!! Thanks really need to go to Jeremy Smith, who asked me to donate it to someone that would give it a good home and appreciate it, and I knew you would do that ans also write some posts to share it with the community, exactly like this. Smile Keep them coming...

--Bob Prosperi
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)