Re: SV: Help 3 vars. equ's (fwd)
[Prev][Next][Index][Thread]
Some people have asked me to send out my program on solving a system of
n equations with n unknowns for the TI-82, so I am writing it here below,
with some commentary on how it works, and some limitations. This is more
of a "GRAPH-TI" kind of topic, but the original request was on this list,
so I've posted it on both.
I hope you don't mind ASCII. My ability to FTP is very
limited where I am.
PROGRAM:SYSOFEQN
:ClrHome
:Disp "THIS PROGRAM"
:Disp "SOLVE AN N*N"
:Disp "SYSTEM OF EQNS
:Pause
:Disp "NUMBER OF"
:Input "VARIABLES? ",N
:{N,N}->dim [A]
:{N,1}->dim [B]
:{N,1}->dim [C]
:1->I
:Lbl 1
:ClrHome
:Disp "EQUATION ",I
:1->J
:Disp "COEFFICIENTS?"
:Lbl 2
:Input A
:A->[A](I,J)
:1+J->J
:If J<=N
:Goto 2
:Disp "ANSWER?"
:Input B
:B->[B](I,1)
:1+I->I
:If I<=N
:Goto 1
:det [A]->D
:If D=0
:Goto 9
:[A]-1*[B]->[C]
:Disp "SOLUTION"
:Disp [C]>Frac
:Stop
:Lbl 9
:Disp "NO ONE SOLUTION"
:Stop
Programming Notes:
Since this is in ASCII, you'll need to use Graph-Link to make some
minor modifications before downloading it to your calculator.
First: Obviously, all of the storing arrows must become storing arrows.
Second, The less than or equal to sign "<=" must be changed.
Third, and most importantly, the line which actually calculates
the solution is supposed to read "Matrix A-Inverse times Matrix B stored
to Matrix C." Be sure it won't accidentally multiply by -1 or subract by
-1, but is actually hitting the "inverse" key.
Fourth, one of the last lines asks you to disply matrix C as a
fraction. Be sure the command is the right one.
Fifth, I realize that something like this might already exist is some
software archive somewhere that I don't know about, and that the algorithm
might be infantile compared to some of the things I've seen posted, but it
works for me. If anyone has any (positive) suggestions as to how to
improve this program, I welcome them.
Sixth, I also realize that the 85 has some built in features that can do
this already as probably does the 92, but for those of us who still are
living and working with 81's and 82's, this serves the purpose.
HOW IT WORKS:
Suppose you wanted to solve the system of equations as follows:
3x + 2y + z = 14
2x - 3y + 4z = 4
x - 4y + 2z = -3
What the calculator will do is set it up as a matrix algebra
problem like so:
[ 3 2 1 ] [ X ] [ 14 ]
[ 2 -3 4 ] [ Y ] = [ 4 ]
[ 1 -4 2 ] [ Z ] [ -3 ]
It reads the information in by rows of the matrix. The first
thing the calculator will ask you is how many variables your system has.
In this case, 3.
When it asks for the coefficients of equation 1, type 3, enter, 2
enter, 1 enter. It will then ask for the answer, which is 14.
Repeat for equation 2's coeffients: 2, enter, -3, enter, 4,
enter, Answer? 4, enter.
Then for equation 3, 1, enter, -4, enter, 2, enter, Answer? -3,
enter.
The first major calculation the program will check is to see if
the matrix of coefficients has a non-zero determinant. If the determinant
of the matrix is zero, then no inverse exists, thus, no solution to the
system. However, if there is a non-zero determinant, then the solution to
the system can be determined by multiplying the inverse of Matrix A (the
matrix of coefficients) by Matrix B (the matrix containing the answers)
and it will both store it into Matrix C and display the results as
fractions (depending upon the determinant of matrix A, you could end up
with some rather ugly answers), but they should all be rational. In this
case, the answer that should be displayed should be
SOLUTION
[[3]
[2]
[1]]
implying that x = 3, y = 2 and z = 1
IMPORTANT SIDE NOTE: The program is not set up to recognize a
trivial solution. As a math student, you should be.
Example: 2x + 3y - 4z = 0
-2x - 3y + 2z = 0
2x + 3y + 4z = 0
The calculator will say there is "NO ONE SOLUTION" since the
determinant of the matrix of coefficients is zero, however, it should be
intuitively obvious that the solution of this system is when x, y, and z
all are equal to zero.
EDUCATIONAL RAMIFICATIONS: I don't allow my students to use this
program until after they have written me a full description about how the
program works, and until after they have taken a test on solving systems
without it.
However, one should note (since someone asked earlier this week)
that this program greatly speeds up Linear Programming problems, with
respect to finding the corner points of a feasible region, which is where
we use this program the most.
Any questions about this program should be addressed to me care of
the address above.
----------------------------------------------------------------------
| | |
| --------- | John M.H. Miyares (aka "Johnny Big Dog") |
| | | Home: 1 Kavanaugh Pl. Bar Harbor, ME 04609 |
| | | Work: Department of Mathematics, MDI High School |
| ----+---- | P.O. Box 180, Mount Desert, ME 04660 |
| | | (h) (207) 288-8272 |
| | | (w) (207) 288-5011, Voice Mail Box #820 |
| ____| | E-Mail: jmiyares@mdihs.u98.k12.me.us |
| | |
-----------------------------------------------------------------------
References: