Re: 33s: parentheses within program (LONG, but COOL alternative) Message #9 Posted by ECL on 24 Feb 2007, 8:28 p.m., in response to message #8 by Adam Price
Adam,
I definetely echo your frustrations with the lack of matrix support on the 33s.
I have successfully used the GaussSeidel method on my 33s. It is a numericiterative approach to solving linear systems. Using it does, however, require you to consider a few characteristics about the system that you wish to solve [you have to think :)]
You must consider the dominant diagonal, the initial value (usually try setting all to zero), among a few others. Don't try to "get it" the first time you read this post, just read through it, and then reread it (perhaps after googling GaussSeidel).
Now, here is one insight...on systems that are appropriate (ie. diagonally dominant, etc) in other words, academic problems that are designed to be solved, you can usually expect a convergence on the correct solution vector.
Anyway, the approach is essentially like this:
1. Take a system, say 4 variables, and algebraically solve each one for one of the variables. So, you solve the first equation for X, the second one for Y, etc.
2. Now, key these in as a 33s keystroke program.
Actually, let me just give a pseudocode to illustrate it:
say we have the following:
Ax + By + Cz = D
Ex + Fy + Gz = H
Ix + Jy + Kz = L
here's the pseudocode:
1. store your coefficients
INPUT A, INPUT B, INPUT C, etc..
2. Solve the first eqn for X:
RCL D, RCL Z, RCL *C, , RCL B, RCL *y, , RCL /A, STO X
3. Solve the second eqn for Y:
RCL H, RCL Z, RCL *G, , RCL E, RCL *X, , RCL/F, STO Y (Note that this equation uses the approximation for X that you just obtained previously...likewise, Step 4 will use both that X and also the Y that you are currently solving)
4. Solve the third eqn for Z, following the above approach.
So the idea is that each subsequent equation in the system gets the most current approximation. If you enter a good system, you can expect convergence. This may at times mean reordering your system (like GaussJordan with pivoting). This essentially means that you flip columns and rows (before entering the coefficients) so that you have a diagonallydominant system.
At this point you want to consider looping through this again, since you will get closer to the actual answer each time you iterate. How to decide when you are happy with the result? Well, consider putting in a check, like compare the new X with the previous X, and set a tolerance like Xo  X < 0.01. This will let the calculator terminate the loop when it begins to split hairs.
As you may realize, there's remains some coding on your part for this to run on your 33s. If it had the USB support like the 50g I'd have posted a link for you. But I'm not up to typing in the whole routine (plus I assume you'd have more fun figuring it out).
The nice thing is that I believe I can run this using at MOST two labels (meaning you don't eat up the volume of registers as the HP code listing does). This leaves more labels for you to store other stuff. You can do this for as large a system as you can squeeze variables. There are tricks like freeing up variables once you've used them to permit a larger system, or even having the code prompt the user for stack entries on the fly to let you run a huge system.
This is why I love machines like the 33s...they really force you to get creative! But, alas as engineers we need problems solved, and must often resort to computers for things like finite element methods. Still, its never a crime to stretch your brains as a student (when many problems are solvable with limited resources) or simply to "pull it off".
Have fun. (To all the detractors of my earlier post regarding the 42s, hope this message warms your hearts and makes you happy that I'm a contributor)
ECL
PS. I'll now "HAVE" to type my afforementioned code out and submit it to D.H. so it can join the program listings on this site.
