Hey everyone! This is my first post and first day dabbling into TI programming. I am having difficulties with a program I tried to make. I saw a video where a guy makes a program that solves systems of equations but I found his code to be painstakingly tedious and unnecessary so I tried to make my own. It pretty much works flawlessly except for the fact that Y comes out to be 0. I used the system of equations in this video to test the program out. At the home screen I hit L/J and it gives me 2, which is the right answer, but for some reason Y keeps coming out to 0, no matter how hard I've tried to fix it. Any help would be appreciated. Thank you! Here is the code:


Code:
Lbl 3
prgmNULL
Disp "X1:"
Input " ",A
Disp "X2:"
Input " ",B
Disp "X3:"
Input " ",C
{A,B,C->L1
Disp "Y1:"
Input " ",D
Disp "Y2 "
Input " ",E
Disp "Y3:"
Input " ",F
{D,E,F->L2
Disp "Z1:"
Input " ",G
Disp "Z2:"
Input " ",H
Disp "Z3:"
Input " ",I
{G,H,I->L3
List>matr(L1,L2,L3,[A])
Disp "Answer 1:"
Input " ",A
Disp "Answer 2:"
Input " ",B
Disp "Answer 3:"
Input " ",C
{A,B,C->L4
det([A])->J
List>matr(L4,L2,L3,[A])
det([A])->K
List>matr(L1,L4,L3,[A])
det([A])->L
List>matr(L1,L2,L4,[A])
det([A])->M
(K/J)->X
(L/J)->Y
(M/J)->Z
Text(1,1,"X = ",X)
Text(16,1,"Y = ",Y)
Text(32,1,"Z = ",Z)
Pause
Menu("Solve Another System?","Yes",3,"No",4)
Lbl 4
ClrHome
Stop
Welcome to Cemetech! I notice you take the determinant of the system; I believe it would be simpler to simply reduce the matrix into reduced row-echelon format via the rref() command, then pluck out the values in the rightmost column of the matrix. Something like this, for instance:
Code:
Lbl 3
prgmNULL
{3,4->dim([A]
Input "X1=",A
Input "X2=",B
Input "X3=",C
A->[A](1,1
B->[A](2,1
C->[A](3,1
Input "Y1=",A
Input "Y2=",B
Input "Y3=",C
A->[A](1,2
B->[A](2,2
C->[A](3,2
Input "Z1=",A
Input "Z2=",B
Input "Z3=",C
A->[A](1,3
B->[A](2,3
C->[A](3,3
Input "Answer 1=",A
Input "Answer 2=",B
Input "Answer 3=",C
A->[A](1,4
B->[A](2,4
C->[A](3,4
rref([A]->[A]
Text(1,1,"X = ",[A](1,4
Text(16,1,"Y = ",[A](2,4
Text(32,1,"Z = ",[A](3,4
Pause 
Menu("Solve Another System?","Yes",3,"No",4)
Lbl 4
ClrHome
Stop
Notice some optimizations:
1) Combining Disp and Input
2) Storing directly to matrix elements instead of via a list
3) Pre-sizing the matrix
4) Re-using A, B, and C each time

By the way, some Cemetech tools you might not be familiar with that might help, including an online TI-BASIC editor and calculator emulator and a book teaching TI-BASIC: http://www.cemetech.net/tools/
Try using a different variable other than Y. When using the graph screen(whether it be for drawing, game playing, or just displaying text), the calculator can sometimes store a value of 0 in Y. I know, it's annoying.

Here's a better explanation, taken from TI-Basic Developer:
Quote:
Caution: if the graph screen is displayed even before you execute ClrDraw, the user variable Y will be reset to 0. This might be useful as a side effect, but it's more likely to turn out to be a nuisance if you were relying on Y to store something useful. Also, such a wacky effect might get removed in later OS versions, so it's a gamble relying on it to work for all users.
KermMartian wrote:
Welcome to Cemetech! I notice you take the determinant of the system; I believe it would be simpler to simply reduce the matrix into reduced row-echelon format via the rref() command, then pluck out the values in the rightmost column of the matrix. Something like this, for instance:
Code:
Lbl 3
prgmNULL
{3,4->dim([A]
Input "X1=",A
Input "X2=",B
Input "X3=",C
A->[A](1,1
B->[A](2,1
C->[A](3,1
Input "Y1=",A
Input "Y2=",B
Input "Y3=",C
A->[A](1,2
B->[A](2,2
C->[A](3,2
Input "Z1=",A
Input "Z2=",B
Input "Z3=",C
A->[A](1,3
B->[A](2,3
C->[A](3,3
Input "Answer 1=",A
Input "Answer 2=",B
Input "Answer 3=",C
A->[A](1,4
B->[A](2,4
C->[A](3,4
rref([A]->[A]
Text(1,1,"X = ",[A](1,4
Text(16,1,"Y = ",[A](2,4
Text(32,1,"Z = ",[A](3,4
Pause 
Menu("Solve Another System?","Yes",3,"No",4)
Lbl 4
ClrHome
Stop
Notice some optimizations:
1) Combining Disp and Input
2) Storing directly to matrix elements instead of via a list
3) Pre-sizing the matrix
4) Re-using A, B, and C each time

By the way, some Cemetech tools you might not be familiar with that might help, including an online TI-BASIC editor and calculator emulator and a book teaching TI-BASIC: http://www.cemetech.net/tools/


Hi! Thanks for your response! I appreciate it! But there are a few problems: 1.) Line 4 gives an error and it seems to stop at the end of the line, where A is and I don't have the knowledge/experience to find out why, 2.) I was using Cramer's Rule, which says that you can find each variable by finding their respective determinants and divide by the original determinant (I kind of find this to be easier) 3.) The reason I wanted to store the values of X,Y, and Z into X, Y, and Z is so that at the homescreen you can manipulate them if you need to. Thanks!
Michael2_3B wrote:
Try using a different variable other than Y. When using the graph screen(whether it be for drawing, game playing, or just displaying text), the calculator can sometimes store a value of 0 in Y. I know, it's annoying.

Here's a better explanation, taken from TI-Basic Developer:
Quote:
Caution: if the graph screen is displayed even before you execute ClrDraw, the user variable Y will be reset to 0. This might be useful as a side effect, but it's more likely to turn out to be a nuisance if you were relying on Y to store something useful. Also, such a wacky effect might get removed in later OS versions, so it's a gamble relying on it to work for all users.


Ah, dang it. Is there any way around this?
HKHolzer wrote:
Ah, dang it. Is there any way around this?

Sure, of course! You can always just use a different variable, or just store to Y after you leave the graphscreen.

As for your other above question, I don't really see a problem with line 4; but try checking to make sure there isn't a space or something at the end of the line. Also, reduced row echelon form does exactly the same thing as you were doing, and you might even learn more about it later on. Good luck, and welcome to Cemetech! Smile

EDIT: Oh, and as a side note, generally posting within 24 hours of yourself, or "double posting" is generally to be avoided. Please just use the [EDIT] button in the top right corner of your post. Thanks! Smile
MateoConLechuga wrote:
HKHolzer wrote:
Ah, dang it. Is there any way around this?

Sure, of course! You can always just use a different variable, or just store to Y after you leave the graphscreen.

As for your other above question, I don't really see a problem with line 4; but try checking to make sure there isn't a space or something at the end of the line. Also, reduced row echelon form does exactly the same thing as you were doing, and you might even learn more about it later on. Good luck, and welcome to Cemetech! Smile

EDIT: Oh, and as a side note, generally posting within 24 hours of yourself, or "double posting" is generally to be avoided. Please just use the [EDIT] button in the top right corner of your post. Thanks! Smile


Thank you so much guys! I got everything to work and cleaned it up a lot! And sorry about the double post haha. The only thing left is, is there any way to display the answers in fraction form so that they are easier to recognize? That is pretty much the only area to improve on this program (as far as my noob eyes can see). Again, thanks so much.

P.S. Here's the final code

Code:
Lbl 3
prgmNULL
Input "X1:",A
Input "X2:",B
Input "X3:",C
{A,B,C->L1
Input "Y1:",A
Input "Y2:",B
Input "Y3:",C
{A,B,C->L2
Input "Z1:",A
Input "Z2:",B
Input "Z3:",C
{A,B,C->L3
List>matr(L1,L2,L3,[A])
Input "Answer 1:",A
Input "Answer 2:",B
Input "Answer 3:",C
{A,B,C->L4
det([A])->A
List>matr(L4,L2,L3,[A])
det([A])->B
List>matr(L1,L4,L3,[A])
det([A])->C
List>matr(L1,L2,L4,[A])
det([A])->D
(B/A)->X
(D/A)->Z
Text(1,1,"X = ",X)
Text(16,1,"Y = ",C/A)
Text(32,1,"Z = ",Z)
Pause
Menu("Solve Another System?","Yes",3,"No",4)
Lbl 4
ClrHome
(C/A)->Y
Stop
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement