(35s) Stackonly quadratic solver

01242021, 11:55 PM
Post: #1




(35s) Stackonly quadratic solver
I know, I know, this is another quadratic equation solver for the 35s. This one, though, is a little different in two ways: a) it operates fully in the stack, modifying no variables, and b) it doesn't use any equations, so while it has more lines, it should theoretically be faster as well.
I also know this isn't one of the awesome highperformance solvers, but figuring out all the stack manipulation was a fun challenge and I'm proud of what I've made. It will find complex roots. Usage: enter a, b, and c onto the stack, in that order, and XEQ Q (or whatever label you choose). You'll get the roots back, or if there's one root, that root on both the X and Y levels. The checksum on my machine is 2F04, with a length of 160. Code: Q001 LBL Q Try it out: say we want to solve 4*x^2  8*x + 3 = 0. To do this, you would follow these steps: Code: 4 [ENTER] 8 [ENTER] 3 The screen should read 0.5 and 1.5. 

06062021, 11:56 PM
Post: #2




RE: (35s) Stackonly quadratic solver
(01242021 11:55 PM)Liam Hays Wrote: I know, I know, this is another quadratic equation solver for the 35s. This one, though, is a little different in two ways: a) it operates fully in the stack, modifying no variables, and b) it doesn't use any equations, so while it has more lines, it should theoretically be faster as well. Take a look at this <https://www.hpmuseum.org/forum/thread15052.html> It is smaller. I don't know if the commands REGZ and REGT I used considered equations or not. 

06072021, 01:26 AM
Post: #3




RE: (35s) Stackonly quadratic solver
I honestly like yours better. I should have realized that I could have used the REG* functions.
mchris Wrote:I don't know if the commands REGZ and REGT I used considered equations or not. I'm not 100% sure, but I think it works like this: if those functions sit alone on a single line, they aren't equations. I think equations are only triggered when you specifically enter one with the EQN key. 

06072021, 09:41 AM
Post: #4




RE: (35s) Stackonly quadratic solver
(06072021 01:26 AM)Liam Hays Wrote: I'm not 100% sure, but I think it works like this: if those functions sit alone on a single line, they aren't equations. I think equations are only triggered when you specifically enter one with the EQN key. But to trigger REGx commands in 35s you have to press EQN and RDN. Anyway I considered them short equations to help the flow of the program. For your information, in HP42s there are equivalent commands like RCL STCK x. In any case I don't consider any gain having 100ms faster code except for a routine which is to be called 100 times a second, like functions for integration. In that last case I have the suspicion that when the program is in ALG mode or has an EQN inside, the 35s translate the whole program before executing it, so the speed remains the same. More tests must be done... 

06072021, 09:48 AM
Post: #5




RE: (35s) Stackonly quadratic solver  
06072021, 06:51 PM
Post: #6




RE: (35s) Stackonly quadratic solver  
« Next Oldest  Next Newest »

User(s) browsing this thread: 1 Guest(s)