The Museum of HP Calculators

HP Forum Archive 18

 HP-35S: Decomposing a complex numberMessage #1 Posted by Antonio Maschio (Italy) on 19 Sept 2008, 12:13 p.m. Well, I don't know if this has already been treated here (I've done some googling, but nothing seems to match), so I present here my way of doing what's in the title for numbers either in the form 'a+ib' or 'r-theta'. Of course, anyone of you may have a better and shorter way, but my scope is not to do some kind of race with anyone, just to help those who face the HP-35S faults. Reading the program by Valentin Albillo about a 35S solver much more powerful than the built-in one (Valentin's one works on real and complex numbers as well and sorry, but I can't find the thread anymore), I grabbed his powerful algorithm to retrieve the real value of any number (either real or complex). Extending its action, I built these short routines to do the same both for reals and imaginary parts, depending on the chosen algorithm. Basing on this assumption, I guess this should be called "Valentin's way", not just "Antonio's way". Note: all routines are for RPN Mode and are all independent of the angle settings (RAD/GRAD/DEG). get Real value -------------- ```R001 LBL R R002 ENTER R003 ARG R004 COS R005 x<>y R006 ABS R007 * R008 RTN ``` get Imaginary value ------------------- ```I001 LBL I I002 ENTER I003 ARG I004 SIN I005 x<>y I006 ABS I007 * I008 RTN ``` Test ---- I performed the following tests, and here's what I got: ```2i7 XEQ I -> 7 2i7 XEQ R -> 2 -2i7 XEQ I -> 7 -2i7 XEQ R -> -2 2i-7 XEQ I -> -7 2i-7 XEQ R -> 2 -2i-7 XEQ I -> -7 -2i-7 XEQ R -> -2 ``` Usage ----- To decompose a complex number do: ```ENTER XEQ I x<>y XEQ R ``` to have the Real part on the display ```ENTER XEQ R x<>y XEQ I ``` to have the Imaginary part on the display Hope this will help someone. -- Antonio

 Re: HP-35S: Decomposing a complex numberMessage #2 Posted by Les Wright on 20 Sept 2008, 1:11 a.m.,in response to message #1 by Antonio Maschio (Italy) Hi Antonio, this deficiency of the 35S was a big headache when I was more active last year. The absence of a function as elegant as the SHIFT COMPLEX key sequence of the 42S is a disappointment in a calculator that is otherwise not bad at maintaining some semblance of the legacy of keystroke programmables. My preference is to link your two routines together into one. I add the extra ENTER at the beginning and put the X<>Y right in the middle in place of the RTN and LBL I. I put mine under LBL D, for Decompose a Complex. XEQ D is similar to the COMPLEX command on the 42S, with the exception that on the 35S the rectangular coordinates are always returned irrespective of mode, whereas with the 42S an complex number in polar form will be decomposed to modulus and argument. In any case the routine is pretty disruptive to the stack. If I have something important in Y, Z, and T, and then put a complex in X and decompose it, only the contents of the former Y register will survive, duplicated in Z and T. Personally, I find it more of a nuisance to create a complex from reals placed on the stack. It is simple but cumbersome--e.g. , in RPN and Rect mode x ENTER y ENTER 0 i 1 * + will return x + iy in the display, but what a bother to do every time, even programatically! And if I want to return a polar complex number from modulus and argument while in Polar mode, it seems even more of a nuisance--I am still trying to come up with a good way to do it. I obviously missed Valentin's post about improving the 35S solver. I would like to see that. The much maligned 33S actually seemed better and faster in this regard. I have a program that computes the inverse normal distribution score associated with a given probability and it requires repeated solves. The built in solver wouldn't even work with my program, so I resorted to writing a short Newton Raphson solver just for the particular problem, given that the function in question had a well known and easily computed derivative. Works well. Thanks for contributing your wisdom on the 35S. I do really like mine, and I even have an unused one still unwrapped, but these little deficiencies do get my goat sometimes. Like the cos(89.999) bug ;) Les

 Re: HP-35S: Decomposing a complex numberMessage #3 Posted by Antonio Maschio (Italy) on 20 Sept 2008, 2:10 a.m.,in response to message #2 by Les Wright Well, you're right. My attempt was more like a study about how to solve the HP-35S faults, rather than a pure and useful routine. In effect, turning the two listings into a unique one may be more useful and less memory-consuming, but in any case I wonder why the engineers behind the HP-35S project didn't manage this. I will look for the HP-35S solver by Valentin when I can (if anyone is not faster than me) and put the link. Thanks for your kind words! -- Antonio Edited: 22 Sept 2008, 2:23 a.m.

 Re: HP-35S: Decomposing a complex numberMessage #4 Posted by Fernando del Rey on 20 Sept 2008, 2:38 p.m.,in response to message #2 by Les Wright Les, I'm not sure of this is the article by Valentin you are looking for, but here's the link to his excellent Complex Roots Solver for the 35s: I really miss Valentin's articles in Datafile, and also his posts on this Forum where we haven't heard from him for a while. Regards, Fernando

 Re: HP-35S: Decomposing a complex numberMessage #5 Posted by Antonio Maschio (Italy) on 22 Sept 2008, 2:22 a.m.,in response to message #4 by Fernando del Rey Thanks Fernando, this is just the article I meant, only... I was looking at the wrong site... Thanks again. -- Antonio

Go back to the main exhibit hall