Best Pol/Rect and Complex Number Decomp for 35S
|
01-26-2019, 12:43 AM
Post: #1
|
|||
|
|||
Best Pol/Rect and Complex Number Decomp for 35S
I would like to know what program(s) are best for Complex Number and Polar/Rectangular and related forms decomposition for the 35S.
Thank you. |
|||
01-26-2019, 02:21 AM
Post: #2
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 12:43 AM)Matt Agajanian Wrote: I would like to know what program(s) are best for Complex Number and Polar/Rectangular and related forms decomposition for the 35S. Nice ->R and ->P programs from Pauli here: http://www.hpmuseum.org/cgi-sys/cgiwrap/...i?read=983 --Bob Prosperi |
|||
01-26-2019, 03:29 AM
Post: #3
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
Thanks! Even though I picked this up several years ago, nice to know its stood the test of time to remain an excellent option.
|
|||
01-26-2019, 03:37 AM
(This post was last modified: 01-26-2019 03:38 AM by Matt Agajanian.)
Post: #4
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 02:21 AM)rprosperi Wrote:(01-26-2019 12:43 AM)Matt Agajanian Wrote: I would like to know what program(s) are best for Complex Number and Polar/Rectangular and related forms decomposition for the 35S. Please refresh my memory and clarify what should be on the stack before I run each routine. Thanks Thanks |
|||
01-26-2019, 10:40 AM
(This post was last modified: 01-26-2019 10:43 AM by ijabbott.)
Post: #5
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 03:37 AM)Matt Agajanian Wrote:(01-26-2019 02:21 AM)rprosperi Wrote: Nice ->R and ->P programs from Pauli here: Looking at the code, program P expects Y=y, X=x, and returns Y=θ, X=r. Vice versa for program R. — Ian Abbott |
|||
01-26-2019, 01:04 PM
Post: #6
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 10:40 AM)ijabbott Wrote: Looking at the code, program P expects Y=y, X=x, and returns Y=θ, X=r. Vice versa for program R. Yes, and if you look closely you'll see these routines preserve the stack (incl LastX) and flags, so they act like built-in functions. Nice! --Bob Prosperi |
|||
01-26-2019, 04:23 PM
(This post was last modified: 01-26-2019 04:47 PM by Dieter.)
Post: #7
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 01:04 PM)rprosperi Wrote: ...if you look closely you'll see these routines preserve the stack (incl LastX) and flags... Yes for the stack and flags, but No regarding LastX. Which is not preserved – on exit it contains a complex number or a vector, respectively. But it can be done. The following modified versions also preserve LastX: Code: P001 LBL P The R routine is even one step shorter. ;-) Equations in programs really are a nice feature of the 35s. They simply return the result in X and push the stack by one level, while no other stack registers – including LastX – are affected. So these programs simply move the original X to LastX (by means of the ABS command in line 004) before they finally return the two results in Y and X. For those who are not that familiar with the 35s equation mode: REGZ and REGT are entered by pressing the [R↓] key and then selecting the respective register X, Y, Z or T from the menu. Stack diagram for →P: Code: T: t t Stack diagram for →R: Code: T: t t Finally, if the state of flag 10 does not have to be preserved the code can be even shorter. In this case remove line 011...014 and replace line 002...003 with "CF 10". Dieter |
|||
01-26-2019, 07:02 PM
Post: #8
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
Excellent, Dieter, as always!
|
|||
01-26-2019, 07:17 PM
Post: #9
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S | |||
01-26-2019, 08:49 PM
(This post was last modified: 01-26-2019 09:16 PM by Dieter.)
Post: #10
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 12:43 AM)Matt Agajanian Wrote: I would like to know what program(s) are best for Complex Number and Polar/Rectangular and related forms decomposition for the 35S. Here is my attempt at a complex decomposition routine: Code: C001 LBL C Stack diagram: Code: T: t z The code has not seen much testing, so please try it, see what you get and report any errors and problems here. Edit: added a few steps to make the routine also work for 0+0i. Dieter |
|||
01-27-2019, 03:47 AM
Post: #11
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-26-2019 04:23 PM)Dieter Wrote:(01-26-2019 01:04 PM)rprosperi Wrote: ...if you look closely you'll see these routines preserve the stack (incl LastX) and flags... Well, that should teach me! I read a post claiming all was preserved and while I bothered to check the flags (by reading code) and the stack contents (by testing), and all was confirmed, I did not check the LastX and extrapolated it too was safe. Never, ever assume... Thanks for this alternate version Dieter. For the 2nd time in a week, after not touching it for a couple years, I've decided to enter programs in my 35S. If I learned about how useful and well-behaved equations are on the 35S when I got mine in 2007, I've totally forgotten it, so Pauli and your programs are good examples of how this feature can be used to build well-behaved functions pretty easily. --Bob Prosperi |
|||
01-27-2019, 08:26 AM
(This post was last modified: 01-27-2019 08:29 AM by Gerald H.)
Post: #12
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
For complex decomposition, returns real part to stack level X & imaginary to variable I:
Code: 1 LBL A |
|||
01-27-2019, 09:14 AM
(This post was last modified: 01-27-2019 03:05 PM by Dieter.)
Post: #13
|
|||
|
|||
RE: Best Pol/Rect and Complex Number Decomp for 35S
(01-27-2019 08:26 AM)Gerald H Wrote: That's a nice approach, with a much less complicated formula than the one I used. Combining it with my original solution the result would look like this: Code: C001 LBL C Maybe this version is a bit more prone to roundoff errors so that the last digit may be slightly off here and there: 1i1 => 0,99999999998, 0,999999999997 -4i3 => -3,99999999999, 3,00000000001 0i3 => 1,4689...E-11, 3 The last example assumes radians mode. OK, this may happen anytime as all we got are 12 digits instead of 15 the 35s uses internally. But on average the more complicated formulas in post #10 seem to exibit less of such problems. In all three cases it returns accurate results. Maybe because sine and cosine of the angle are avoided (only their sign is considered). Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)