Valentin Albillo's "Boldly Going... Going Back to the roots" now for the HP-41 !
|
04-16-2024, 08:05 AM
(This post was last modified: 04-16-2024 12:02 PM by Vincent Weber.)
Post: #1
|
|||
|
|||
Valentin Albillo's "Boldly Going... Going Back to the roots" now for the HP-41 !
Hi all,
A few months back, I ported Valentin's albillo efficient complex solver (see his article) from the 35S to the 42S and to the 32SII/DM32. Porting it to the 42S was trivial, as both the 35S and the 42S can deal with complex numbers easily (on the stack and in storage registers). Porting it to the 32SII/DM32 was another pair of shoes. Those only have a 2-level complex stack instead of 4, and lack complex registers. So porting the program was more complicated: not only every STO/RCL had to be doubled, but moreover, anything needing more than 2 numbers on the stack (like / followed by +) had to use temporary storage. Porting it to the 41 was even more complicated, since the 41 doesn'have complex numbers at all. Well, you have the Advantage Pack's crude RPN routines, but those use registers, which is a headache when your program also needs a lot of registers ! You could use Angel Martin's awesome MCODE 41Z module, or even the TOULMATH module (which replicated the 15C complex stack in MCODE), but none of these ware available to the user back in the day, so this would be cheating... I found a simple way, reading the software library on this very forum: Jean-Marc Baillard actually wrote his own 2-level stack RPN complex functions (here), with several improvements over the Math/Advantage Pack: - No registers used at all; - Simpler usage; - Complete trigs and hyperbolics. Jean-Marc also wrote his own complex solvers, which work fine. However, they are not as elegantly simple as Valentins's, they require 2 or 3 estimates, or even to compute first and second order derivatives, vs. only one estimate. But this gave me the idea of the port... So, first key-in Jean-Marc's complex stack functions. Hint: rather than your fingers (only the text is provided), copy the text, paste into Free42/Plus42 (pasting is very powerful), and then export it into a 41C-compatible raw file than you can email to yourself ! As for the port itself, here we go. Please note that whenever Valentin used a lettered 35S complex register, I used the corresponding numbered register (e.g. X became 24) for the real part, and then I used registers as needed for the imaginary parts, starting with 01. Registers 07 to 18 are free to use in your own equations programs. Register 00 has to hold the equation program's name in alphanumerical form (use ASTO 00 to store it). The program is called "RZVA" for "Root Z (complex) from Valentin Albillo" Code:
Here is an example function to use. This is the first example from Valentin's article (Z^Z-R=0). The program expects the complex variable to be stored in X (from the 35S), which means register 26 (for the real part) and 01 (for the imaginary part). The constant R has to be stored in registers 9 (real) and 8 (imaginary). Here R = i, so R08 = 1 and R09 =0. Code:
Juste do EQ1 ASTO 00 to store the equation, put 1 and 0 on the stack for the estimate (i), and voilà. This works perfectlly... except for one thing: it is slow as hell !! Basically, take Valentin's timings in his article, they are expressed in seconds, well, take the same numbers expressed in minutes, you'll get an idea on how slow it is. I cheated by accelerating the emulated 41 in i41cx+. Even at max speed, this is still quite slow. The 41 is a slow machine to begin with, the RPN complex routines and constant need for intermediate storage doesn't help either... but if you are patient, now your bare-bones 41 can solve any complex equation ! Comments welcome of cours. Cheers, Vincent |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 5 Guest(s)