WP34S: Valentin Albillo's Polynomial Root Finder - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: WP34S: Valentin Albillo's Polynomial Root Finder (/thread-205064.html) |
WP34S: Valentin Albillo's Polynomial Root Finder - Miguel Toro - 11-17-2011 Hi, Here is a version for the WP 34s of Albillo's original program for the HP 41. I would like to thank Ángel Martin for helping me with lot of information, documentation and his own version for the 41z. Porting the program was very straightforward. The only real difference I found between commands was with the SIGN function that behaves like it does in the 3Xs family rather than it does in the 41 and 42 calculators, so I have to replace it in my code. The program has been tested with version 2.2 rev. 1782. Just copy it in a file and assemble it to try in the emulator and the calculator Testing the examples from the article on the calculator, I obtained the same results, with the following time: Example 1) 5 seconds – original on HP 41: 8 minutes : (2+8i)z^6 + (3+0i)z^5 + (-1+2i)z^4 + (0+2i)z^3 + (-3-3i)z^2 + (1+2i)z + (-2+3i) =0 Example 2) 3,5 seconds – original on HP 41: 5 minutes : 5x^6 – 4x^5 – 3x^4 + 8x^3 + 8x^2 – 2x + 7 = 0 Note: You can delete the STOP in line 34. It is there just for testing. Enjoy! Miguel
001 LBL'PRT'
Edited: 17 Nov 2011, 1:06 p.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Ángel Martin - 11-18-2011 Bravo Miguel! This contributes to create a 34S library :-) The next should be the Bessel functions - Complex of course - sure the 41Z programs can also help! Looking at the 34S code I can recognize a couple of tricks I used to adapt the program to the 41Z - nice to see the design similarities, which on the other hand are pretty logical choices. I'm thinking about Valentin's examples in the other thread - would be good to test the port with those and see how it fares, sort of "turning the creature against the creator" :-) the first one was:
x^20+10 x^19+55 x^18+210 x^17+615 x^16+1452 x^15+2850 x^14+ which Wolfram Alpha reports (Thanks Gerson!) having coincident roots at:
x = -1/2 - sqrt(3)/2*i
Best, Re: WP34S: Valentin Albillo's Polynomial Root Finder - Paul Dale - 11-18-2011 Quote: What in particular?
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Ángel Martin - 11-18-2011 The way to push the complex argument into the complex stack with independence from the real one, and also checking on the complex round as opposed to on each real and imaginary parts - as it was done in the original program. Trivialities when seen in retrospective but it was different when you also had to write the MCODE underneath all the functions to play well in that scheme.
ÁM
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Paul Dale - 11-18-2011 Quote: We don't separate the stack into a complex and real sections -- everything lives on the single stack. X + iY, Z + iT, A + iB and C + iD. The latter two being optional. I did add complex STO and RCL commands to make life easier. - Pauli
Edited: 18 Nov 2011, 2:36 a.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Dieter - 11-18-2011 Looking at the code, I would like to add a few comments:
Dieter
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Miguel Toro - 11-18-2011 Hi Dieter, Excellent and pertinent remarks! There is a lot of heritage from the original code that is not required with the WP 34s. In this version I just made the more obvious changes and improvements, thanks to the excellent complex instruction set of the 34S, just to test how easily was to port code from the 41. I will modify the program based on your comments. Thanks and regards, Miguel
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Dieter - 11-18-2011 Here's a first attempt of a modified version for the 34s. I'm sure there's room for improvements, maybe there are even some errors. The algorithm is the same, basically the following details have been changed:
001 LBL'PRT'Here's an example: x^4 - 4 x^3 - 3 x^2 + x + 1 XEQ"PRT"Once calculated, the results can be recalled by XEQ"RES". By the way: Walter, I miss a directly accessible "=" on the alpha keyboard. As far as I can see, common prompts like the "N=?" in line 007 cannot be entered from the keyboard. However, there are several unassigned keys on the alpha keyboard: Just as h [4] enters a question mark, h [5] could be used for the missing "=".
Dieter
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Walter B - 11-18-2011 Dieter, thanks for pointing this out. I'd put '=' on h-shifted ENTER in alpha mode - the location CONST lives.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Marcus von Cube, Germany - 11-18-2011 '=' is in the test catalog of course. In multi alpha mode I've put it on the same key (no catalogs available then) in the most recent build. h ENTER^ produces an up arrow.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Walter B - 11-19-2011 As often before, this is not finally discussed nor agreed on yet. Some procedures seem quite difficult to teach ;-) And a catalogue access is not a direct access 8-) Edit: Meanwhile, we agreed on putting '=' on h-shifted R/S in alpha mode, the key it lives nearly everywhere ;-)
Edited: 19 Nov 2011, 5:15 p.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - fhub - 11-20-2011 Quote:Hi Dieter,
it seems you have indeed changed it a bit too much - your version doesn't even solve the simple polynomial x^10+1=0.
Franz
Re: WP34S: Valentin Albillo's Polynomial Root Finder - fhub - 11-20-2011 Quote:Hi Angel, either you have mistyped any coefficient(s), or Miguel's translation is not correct, or Valentin's program does indeed not solve this polynomial at all!? I've entered this polynomial now 3 or 4 times and waited about 2 minutes (on the PC emulator of WP34s), but no solution - it just didn't stop running. So I guess I'll stay with my own new polynomial solver (with Laguerre method), which solves all those polynomials without any problems (even the 2 'hard' ones that Valentin has posted), and is in fact much faster and gives more accurate solutions. :-)
Franz
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Dieter - 11-20-2011 Yes, the more sophisticated convergence test was a bit too ...sophisticated. ;-) It does not work if a root is very close to zero and decides that two consecutive approximations do not agree even if their real parts are 1E-24 and 1E-25. In your example the problem arises at the fifth and sixth root (i and -i). Their real part is exactly zero while the program actually has determined a value near 1E-16.
Here's an improved version. It checks whether the real and complex parts either agree in all displayed digits or if they both are virtually zero. ... ... Dieter
Edited: 20 Nov 2011, 9:12 a.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - fhub - 11-20-2011 Quote:Have you tried Valentin's 20-degree polynomial which Angel has re-posted above? Let's see if your new version is now sophisticated enough for this one ... ;-) Or you could even try the 30-degree polynomial Valentin has posted as test for my first (Bairstow) solver. It has the only solution x=-1 (but with multiplicity 30), and my new Laguerre solver gives the exact solution 30-times! :-)
Franz
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Ángel Martin - 11-20-2011 My questions exactly :-)
Re: WP34S: Valentin Albillo's Polynomial Root Finder - fhub - 11-20-2011 Quote:Well, I've tried at least the 20-degree poly (with Miguel's translated program),but got no solution at all. So I didn't try the 30-degree one. Re: WP34S: Valentin Albillo's Polynomial Root Finder - Dieter - 11-20-2011 Franz, Quote:there obviously is a misunderstanding here. This is not "my" solution of a polynomial root solver. Honestly, I do not plan on writing something like this - my knowledge on this topic is very limited. What you see is simply Miguel's original PRT version with some minor improvements (input/output, convergence test, special 34s features). The whole algorithm is exactly the same as before. So if the original version does not handle the 20-degree-polynomial, the modified version will not do so either. So it's about time for you to show your latest Laguerre solver. ;-) Dieter
Edited: 20 Nov 2011, 2:08 p.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - fhub - 11-20-2011 Quote:No Dieter, not after these attacks a week ago! Since this time my programs are only private.
Franz
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Andrés C. Rodríguez (Argentina) - 11-21-2011 Franz, Of course, it's your choice to share your knowledge with the community or not; but it's puzzling that such a decision is made upon the result of a single event or exchange with one or two persons. Many contributors, even very bright ones, received some unexpected, unfair or out-of-style feedback from time to time; I recall some cases and I'm sure there are more. And sometimes the language differences, personal styles, local/country jargon, sense of irony, and translations add up to make a supossedly friendly message look more aggressive than intended. Sometimes any of us may be on the receiving side of such messages and sometimes, even by accident, may be at the originator side. But the decision to share or not is up to each one of us. Many people come here just to learn from others' creations and discoveries, and an implicit thank you is available for all contributors each time they post interesting and useful material. Please see that I'm not trying to analyze, explain, or otherwise support or condemn the opinions and postings of any other member of this community. Best regards.
(I apologize in advance if my imperfect command of the English language prevents this message to convey its friendly and positive intentions)
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Walter B - 11-21-2011 Just crossed my mind whether we need a general disclaimer all of us writing in English as a foreign language should append to our postings in this forum. This won't, however, cover the numerous spelling or even wording errors by authors with "English" as their mother tongue observed here. Anyway, since it won't take care of all cases I remember having seen here, forget it ;-)
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Ángel Martin - 11-21-2011 what about this for a disclaimer: "get a grip"
:-)
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Miguel Toro - 11-22-2011
Quote: I tried this example with the original 41 program entered in the V41 emulator and it does not converge either. I did it several times in case I made any mistake entering the data. So I think that my translation is as faithful as it can be but one never knows... With both versions in FIX 6, results are really similar; and putting simply FIX 11 in line 041 or the wp34s version, accuracy is very much improved for many other cases I tested, but this one in particular, seems to be really tough :-). As disclaimed by Valentin in his article : "convergence is not guaranteed". What I am going to do: 1.- let the program as simple and near the original as possible, 2.- include some of the improvements suggested by Dieter, 3.- add an iteration limit so the program may stop with a “no zero found” message, 4.- put it in the Article section, so there is at least a solver available until some improved version is made by one of the many knowledgeable peoples of this community (someone please give a WP 34S to Valentin! I am sure he will enjoy). Thanks and regards,
Miguel Edited: 22 Nov 2011, 10:35 a.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Peter Murphy (Livermore) - 11-22-2011 Walter, you are correct: there are so many Forum participants who write excellent English despite its not being their mother tongue that it is easy for native speakers of English to assume that everyone here can communicate with perfect clarity. You are also correct that some cases seen here do not result from imperfect English: perfect clarity is sometimes the problem. My suggestion: if we treat our communications here as if they were delivered face to face, we might be less likely to speak in ways that give offense. And in cases of seeming offense, we might do well to let a matter rest overnight before responding, if we respond at all. In cases of offense, sincere and humble apology does wonders.
Finally, remembering our purpose in participating in the Forum, namely to increase the enjoyment and utility we and others get from HP calculators, might do a lot to reduce the number of cases arising.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Werner - 11-23-2011 I'd like to see Valentin's original program. I searched through PPC Journals in vain for it. (x^2 + x + 1)^10it's no wonder all polynomial solvers choke on it - well at least those that do not check for multiple roots up front (which can only really be done when you have exact coefficients, as is the case here). For a root with multiplicity n, (n-1)/n of the digits of the result will be inaccurate. Cheers, Werner
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Ángel Martin - 11-23-2011 Hi Werner, the reference is:
PPC TECHNICAL NOTES (the Australian Chapter if I´m not mistaken) Hope this helps, I can mail it to you if you still can't locate it - let me know.
Best, Re: WP34S: Valentin Albillo's Polynomial Root Finder - Werner - 11-23-2011 Can't locate it.. it's not on TOS, and not on the Museum's DVD..
Werner
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Miguel Toro - 11-23-2011 Hi, You can find the program here in the article section. There is now an iteration limit in case there is no zero found. Regards,
Miguel Edited: 23 Nov 2011, 7:40 p.m.
Re: WP34S: Valentin Albillo's Polynomial Root Finder - Werner - 11-25-2011 Thanks for the file, Angel.
Cheers, Werner
|