WP34s: linear equation system  Printable Version + HP Forums (https://archived.hpcalc.org/museumforum) + Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum1.html) + Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum2.html) + Thread: WP34s: linear equation system (/thread190580.html) 
WP34s: linear equation system  fhub  08142011 Now that we have an extended quadratic equation solver, what about a simple linear equation system solver for 2 variables?
Here's my code for this (SLVL, SLVS or SLVLS ?): /*It preserves the coefficients of the 2nd equation (d,e,f), puts the coefficient determinant to Z and the solution x,y to X,Y. Of course it works only in SSIZE8 mode! With the use of Pauli's 'private' ;) internal registers it could even preserve ALL coefficients, if e.g. the determinant would be stored to register L (or simply ignored). If you want you can include it in the XROM, if not then it's just one more little user program ... ;) Franz
Edited: 14 Aug 2011, 8:54 a.m.
Re: WP34s: linear equation system  Paul Dale  08142011 Quote: and
Quote: are exclusive. So a library routine it will have to be.
Re: WP34s: linear equation system  Paul Dale  08142011 Is there a reason you've got three cross products (of the form a b  c d) here but aren't using complex multiply to maintain accuracy?
Re: WP34s: linear equation system  fhub  08142011 Yes, I was already afraid that SSIZE8 might be a problem for XROM.
Now for another idea I had today: ;) I think this would be very easy to implement (if I don't overlook something?), because such a "STO Y to I" could simply be done whenever X is stored in L. Good idea or not? ;)
Franz
Re: WP34s: linear equation system  fhub  08142011 Quote:Yes, there are even a few reasons! ;)
1) I would have to put all 4 values (used in [cpx]*) at the right position on the stack, which would cost a lot of program steps
Franz
Re: WP34s: linear equation system  Marcus von Cube, Germany  08152011 Franz, neat little program. One more idea which might even allow for Pauli's idea to compute the determinant with a complex multiply: Why not enter the complete system column wise or coefficients first, then right hand side? If the routine would preserve the coefficients in stack levels Z, T, A & B and a allow to enter another set of values for the right hand side to solve a similar system without reentering the matrix.
Pauli, even if in XROM the stack mechanics a nailed to 4 levels, all 8 registers are still available so that a program which expects data in registers A to D can still be written. It may consume more steps but we have some room left.
Re: WP34s: linear equation system  Paul Dale  08152011 Quote: XROM is for built in commands. Playing games like this with the stack & registers really isn't appropriate :( The command has to work regardless of the stack size and the user's settings. In a library, things are very different however.
Re: WP34s: linear equation system  fhub  08152011 Quote:Yes Marcus, the idea with preserving the coefficients is indeed a very good one, and also using the complex multiply would be preferable, but both ideas require to use additional registers Rnn  it's just not possible to do this with an 8level stack (at least not without dozens of "stackswappings"). So if you would say using additional registers is ok, then I would certainly give it a try ... ;)
But what surprises me a bit more at the moment: my idea above (having an additional "LastY" (i.e. storeing Y in "I") to the usual "LastX" in L) doesn't even seem to be worth any answer!?
Franz
Re: WP34s: linear equation system  Marcus von Cube, Germany  08152011 For me your suggestion about LastY sounds reasonable. Let's wait what the others think about it.
Re: WP34s: linear equation system  Paul Dale  08152011 Since you are pushing the point, I hope you can deal with a bit of negativity :)
Complex dyadic operations would require a complex equivalent of last Y. Triadic operations would require a last Z. Fortunately, there are no complex triadic operations yet or we'd require more. We simply can't stay consistent treading this path. Now think about the number of times you've used register I as a temporary (& I've seen your code doing just this and I've done the same many times). Users can and will do this. Adding a last Y using "I" will impact this use of the register. So, yes we considered this and rejected it. Now, we could use our final bit in the mode word to specify an optional stack backup before every operation or not. That would achieve pretty much the same thing. Is this worthwhile? I really don't know.
Re: WP34s: linear equation system  Marcus von Cube, Germany  08152011
Quote:
This reminds me of the "Last Stack" feature of the RPL machines. I think it's overkill. We should consider to put STOS and RCLS on the keyboard instead (where ITOA and ATOI reside now) and to allow register A as the destination if in SSIZE4 mode.
Re: WP34s: linear equation system  Paul Dale  08152011 Quote: Allowing A is problematic and would require some work in the argument processing code. I also think it is overkill.
Re: WP34s: linear equation system  fhub  08152011 Quote:Well, a bit of negativity won't be a problem for me, but as far as I can remember each and every idea or suggestion from me to improve the 34s has been rejected by you so far  either "not useful" or "not possible"! So since it seems that all my ideas are in fact that bad, I guess it's better for me (and you) if I completely resign from the 34s project. Franz
Edited: 15 Aug 2011, 6:11 a.m.
Re: WP34s: linear equation system  Paul Dale  08152011 Grow up. We've taken several of your suggestions on board and I expect we'll accept more in the future. Just not this one.
Re: WP34s: linear equation system  Marcus von Cube, Germany  08152011
Quote:Yes, I know. But I still thinks it's worth the effort. So with a 4 level stack, A to D can assume the role of a quick backup. Re: WP34s: linear equation system  Paul Dale  08152011 What about a SWAP4 command? Swaps X, Y, Z & T with A, B, C, & D. Not quite as good as a STO/RCL of the stack but useful I think.
Re: WP34s: linear equation system  fhub  08152011 Quote:I would rather say you should grow up! Your usual stubborn argument "because it won't work for all functions, we don't implement it at all" is pure nonsense, and I really can't hear it anymore! Because you won't have a LastZ for a few single 'exotic' triadic functions (or for complex functions), you don't implement such an extremely useful LastY feature at all? Just because a few percent of functions (certainly used very seldom) can't profit from such a feature, all other (maybe 95%) functions shouldn't profit from a LastY, too? Sorry, but that's just ridiculous. (I guess you would also reject a 2nd prize in a lottery just because you didn't win the 1st prize?) Quote:May I laugh? Yes, I'm good enough for you to improve and optimize some code (crossproduct, TVM, SOLVQ), but when it comes to ideas or suggestions your opinion is that I should better shut up. Thanks, but I'm not your slave  it's really enough now!
Goodbye  an my best wishes to the WP34s team,
Re: WP34s: linear equation system  fhub  08152011 Quote:LOL, that's funny: exactly my idea from a few days ago ... All 3 features (Save/Restore/Swapstack between the lower and upperstack were my suggestions a few days ago (and I've even provided usercode for all 3 commands), and what answer did I get? "not needed, you can use STOS and RCLS instead" And now when Marcus (and even Pauli himself) 'suggest' exactly the same features, they are now suddenly "useful"?
Sorry, but I couldn't resist ... ;) Edited: 15 Aug 2011, 7:44 a.m. after one or more responses were posted
Re: WP34s: linear equation system  Marcus von Cube, Germany  08152011 Some suggestions just take their time... ;)
Re: WP34s: linear equation system  Walter B  08152011 Number 13 and counting ;)
Re: WP34s: linear equation system  Paul Dale  08152011 I've figured out the "best" way to do the swap4 command:
LBL'SW4' Seven instructions = 14 bytes. To introduce an internal command table entry takes 12 bytes and to add a function that does nothing pushes things closer to 40 bytes. To add the relevant swaps pushes this higher. So this is the most compact implementation I can think of. The question is to do this as a user subroutine  no extra flash bytes but 7 user steps  or put it in xrom as is  14 bytes  or to put it in xrom with an internal command to call it  30+ bytes  or to write a dedicated command  60+ bytes. I'm leaning towards letting the user do this one.
Re: WP34s: linear equation system  Marcus von Cube, Germany  08162011 Now add another label, LBL 32, and XEQ x<>y does the swap from the keyboard as long as the PC is positioned in the correct region.
