TI-89 Row Reduction Program Troubleshooting

In summary: I'll try that next time.In summary, the TI-89 is able to do matrix row reduction, but sometimes it doesn't do it completely. Evgeny suggests trying to debug the program by printing out the matrix it is working on.
  • #1
0rthodontist
Science Advisor
1,231
0
I wrote this in September so that I could do matrix row reduction on my TI-89. It works, usually, but sometimes it doesn't row reduce all the way. Any ideas what I've done wrong? Or is it just some strange quirk of the calculator?

If you don't know TI-89 code, it is self explanatory except for a few built in matrix functions which I explained with C++ style comments.

Code:
solvemat(x)   	// the name of the function.  x is the matrix
Func           	//stating that it is a function and not a program
Local j, L, i, k, o  // These are integers.  Note:  
		//Sorry about the non-
		//descriptive names, I had to type on an 
		//alphabetic non-qwerty 
             	//keyboard so I didn't want them to be long
// j and L will be dealt with shortly
// i is the loop variable for columns
// k is the loop variable for rows
// o keeps track of the last row that properly starts with a 1

colDim(x) - 1 -> j  //colDim(x) = number of columns in x.  -> j 
                   // means "assign to j"
rowDim(x) -> L 	  //rowDim(x) = number of rows in x
0->o             //o is initialized to 0
For i, 1, j, 1  // for(i = 1; i <= j; i++)
	o+1 -> k
	While x[k, i] = 0
		k + 1 -> k
		If k > L
			Goto down //I know it's lame but there
	EndWhile		//is no "continue" in TI-89 basic

	mRow(1/(x[k, i]), x, k) -> x

		/* this built-in matrix solving function means 
		   "multiply row k of matrix x
		   by 1/(x[k, i]) and put the result back into
		   matrix x." What I am doing here is putting
		   a 1 at the beginning of the row */

	rowSwap(x, k, o+1) // swaps row k and row o+1

	o+1 -> o	//I could have done this a line earlier
			// and had neater code, but I didn't
 
/* Now I have a row that is in the proper location, and it has
 a 1 at the beginning of it.  Now I will use that row to
 eliminate all the nonzero elements of the matrix above and below the 1. */

	For k, 1, L, 1 // for(k = 1; k <= L; k++) also L = 
			// rowDim(x) from earlier

		If k = o // that's an 'o'
			Goto d2

		If x[k, i] != 0
			mRowAdd(-x[k, i], x, o, k) -> x

	/* This built-in matrix solving function means
	"multiply row o of matrix x by -x[k, i] and add the
	result to row k, and the resulting matrix goes back
	into matrix x */

		Lbl d2
	EndFor
	Lbl down
EndFor

Return x

EndFunc

The matrix I am trying to do is
1 -1 0 5
-1 1 5 2
0 1 1 0

The solution of this matrix is
1 0 0 18/5
0 1 0 -7/5
0 0 1 7/5

But my function, solvemat(x), spits this out instead
1 1/4 0 13/4
0 5/4 0 -7/4
0 -1/4 1 7/4

If I do solvemat(solvemat(x)) it finishes the row reduction and returns the correct result. And the strangest thing is that if I alter the "1" in position (2, 2) of the original matrix x, the program runs correctly even if I only altered the 1 to, say, 1.000001.
 
Physics news on Phys.org
  • #2
Probably the easiest way to debug it is to have it frequently print out the matrix, so you can watch what steps its performing, and in what order. That way, you can see when it's doing something wrong.
 
  • #3
I notice that you have a conditional checking when x=0, what happens if due to round off errors x is very close to (as close as the calulator can get) but not equal to zero. If you were to check for x< (some very small number) You might resolve your problem.
 
  • #4
The TI-89 has this function built-in using the simultanious equation solver flash-app that comes installed by default. After you enter your matrix (leave it in homogenious form - the solution side of the augmented matrix doesn't really make a difference) press solve, and after that, I forget the exact function key you have to press, but its labled something along the lines of "view". It will switch between different views, including one that you are looking for. I believe there's also a way to export the solution as a matrix.

As far as your program, it must be rounding error somewhere as others have already stated. I'll give the debugging a go once I get home (don't have my 89 with me).
 
  • #5
Ah, no, it's not roundoff, I found the bug and forgot to post it. The bug is:
rowSwap(x, k, o+1)
It should be
rowSwap(x, k, o+1) -> x

Thanks evgeny, I didn't know that.
 

Related to TI-89 Row Reduction Program Troubleshooting

1. What is a row reduction program and how does it work?

A row reduction program is a mathematical tool used to simplify and solve systems of linear equations. It works by applying a series of operations, such as multiplication and addition, to the rows of a matrix in order to transform it into a simpler form.

2. How do I know if my TI-89 row reduction program is functioning correctly?

You can check the accuracy of your program by manually solving a system of equations and comparing it to the output of your program. Additionally, you can test your program with different types of equations to ensure it is producing consistent and correct results.

3. What should I do if my TI-89 row reduction program is not giving me the correct answer?

If you are consistently getting incorrect answers, check for any errors in your program's code. Make sure you are using the correct syntax and inputting the equations correctly. You may also want to try using a different row reduction program or manually solving the equations to verify the results.

4. Can I use a TI-89 row reduction program for all types of equations?

No, a row reduction program is specifically designed for linear equations. It may not work for other types of equations, such as quadratic or exponential equations.

5. Is there a limit to the size of matrices that can be solved using a TI-89 row reduction program?

Yes, the TI-89 has a limit of 10 rows and 10 columns for matrices. If you have a larger matrix, you may need to break it down into smaller matrices or use a different tool to solve it.

Similar threads

  • Engineering and Comp Sci Homework Help
Replies
10
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Calculus and Beyond Homework Help
Replies
8
Views
306
  • Linear and Abstract Algebra
Replies
8
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
10
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
1K
  • Engineering and Comp Sci Homework Help
Replies
7
Views
2K
Back
Top