Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
system of linear equations solver code
#1
Hello every body.
I need a code to run it in qbasic and solve the system of equations
AX=B where A is N*N and B is N*1 by using the numerical methods.(like as Gauss elimination-
LU factorization -gauss jordan and ....)
(My A matrix may have large dimension like 30*30)
Thank you
Reply
#2
Check the previous thread you started. I have an answer for you in there...
Antoni
Reply
#3
Dear Antoni
I am very thankful to you for answering my question and sending me
the code for solving linear system of equations.
but would you please send me the quickbasic code as a program not as a
subprogram because I don't know to use subprogram in quickbasic.
I need a code to run it in qbasic and solve the system of equations
AX=B where A is N*N and B is N*1 by using the numerical methods.(like as Gauss elimination-
LU factorization -gauss jordan and ....)
(My A matrix may have large dimension like 30*30)

I have also a program solve the system of linear equations by gauss elimination method
but it is not complete and doesn't change the rows of matrix to locate the biggest value
in diagonal of matrix in each step. for example a11=0 and it gives error.
here is my program.(It needs changing the rows and columns and pivoting but I don't know how to put this part in program)
Thank you
Code:
' PROGRAM GAUSS- SOLVES A MATRIX EQUATION C(N,N)X(N)=V(N)
  '                BY GAUSSIAN ELIMINATIN METHOD.
  '                X AND V SHARE SAME STORAGE SPACE.

  CLS
  PRINT "PROGRAM GAUSS -SOLVES MATRIX EQUATION C(N,N)X(N)=V(N)"
  PRINT "               BY GAUSSIAN-ELIMINATION METHOD."
  PRINT
  INPUT " THE ORDER OF MATRIX EQUATION,N:"; N
  DIM C(N, N), V(N)
  PRINT
  PRINT "INPUT THE ELEMENTS OF THE COEFFICIENT MATRIX ROW BY ROW"
  PRINT "AND PRESS <ENTER> KEY AFTER ENTERING A NUMBER:"
  FOR I = 1 TO N
  FOR J = 1 TO N
  INPUT ; C(I, J)
  NEXT J
  PRINT
  NEXT I
  PRINT
  PRINT "INPUT THE ELEMENTS OF THE CONSTANT VECTOR:"
  FOR I = 1 TO N
  INPUT ; V(I)
  NEXT I
  FOR I = 1 TO N         '***** NORMALIZATION
  FOR J = I + 1 TO N
  C(I, J) = C(I, J) / C(I, I)
  NEXT J
  V(I) = V(I) / C(I, I)
  IF I = N THEN GOTO 271
  FOR K = I + 1 TO N
  IF C(K, I) = 0 THEN 265 ELSE V(K) = V(K) - C(K, I) * V(I)  '*** ELIMINATION
  FOR J = I + 1 TO N
  C(K, J) = C(K, J) - C(K, I) * C(I, J)
  NEXT J
265  NEXT K
  NEXT I
271 FOR I = N - 1 TO 1 STEP -1
FOR J = I + 1 TO N
V(I) = V(I) - C(I, J) * V(J)
NEXT J
NEXT I
PRINT
PRINT
PRINT "THE SOLUTION VECTOR HAS ELEMENTS:";
FOR I = 1 TO N
PRINT V(I);
NEXT I
PRINT
PRINT
END
Reply
#4
You might want to use matlab instead then.
oship me and i will give you lots of guurrls and beeea
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)