"Play it again, ZSam..."
02-15-2017, 07:59 AM (This post was last modified: 03-02-2017 06:08 AM by Ángel Martin.)
Post: #1
 Ángel Martin Senior Member Posts: 1,374 Joined: Dec 2013
"Play it again, ZSam..."
a.k.a. Solving systems of non-linear equations using the successive approximations method (SAM)... in the complex domain (Z).

Now that we got the long title done and over with, the actual description should be a breeze...

First off, this routine adapts to the 41Z platform the method published by JM Baillard (see here). A few program lines needed changing, mainly to adjust the registers mapping to the convention used by the 41Z. Using 41Z functions also reduced the code size, which is always welcome.

This program includes routines for data entry and output of results - so it's a "driver"of the core routine published in JM's page. This provides a convenient way to use it.

This method requires one equation in explicit form for each of the n-variables, thus n-equations in total as global labels in RAM. The global label names are prompted, as well as n guess (complex) values to start the iterative process. It's not a fast approach, so don't expect blasting speed - yet should be a reliable method with sensible initial guesses.

Using the same example given in the above reference:

z1 = ( z1^2 - z2 )^1/3 ,
z2 = ( z2^2 - z1 )^1/4

programmed as follows:

Code:
01  LBL "Z1="    11  LBL "Z2=" 02  ZRCL 01      12  ZRCL 02 03  Z^2          13  Z^2 04  ZRCL 02      14  ZRCL 01 05  Z-           15  Z- 06  3            16  4 07  Z^1/X        17  Z^1/X 08  RTN          18  END

Using (1+i) as initial guesses for both z1 and z2, the results are obtained in a few seconds on the 41-CL, or with an emulator in Turbo mode.

z1 = R02 + i R03 = 1.038322757 + 0.715596476 i
z2 = R04 + i R05 = 1.041713085 - 0.462002405 i

And here's the program code in all its glorious splendor:-

Code:
01    LBL "ZSAM"  02    SIZE? 03    "N=?"  04    PROMPT 05    STO 00 06    3 07    * 08    E  09    + 10    X>Y? 11    PSIZE 12    XEQ 00 13    RCL 00 14    E3/E+ 15    ZINPT 16    LBL 01 17    VIEW 02 18    CLA 19    RCL 00 20    ST+ X 21    STO M 22    LBL 02 23    RCL 00 24    ST+ X 25    E 26    + 27    RCL M 28    + 29    RCL IND X 30    RDN 31    XEQ IND T 32    ZENTER^ 33    ZRCL IND M(5) 34    Z- 35    ZMOD 36    ST+ N(6) 37    DSE M(5) 38    GTO 02 39    X<>N 40    E-8 41    RCL 00 42    * 43    X<Y? 44    GTO 01 45    RCL 00 46    E3/E+ 47    ZOUPT 48    RTN 49    LBL 00 50    RCL 00 51    ST+ X 52    2.1 53    + 54    STO 02 55    RCL 00 56    E3/E+ 57    STO 01 58    AON 59    CF 23 60    LBL 05 61    "F#"  62    ARCLI 01 63    " |-? "  64    ARCL IND 02 65    STOP 66    FS?C 23 67    ASTO IND 02 68    ISG 02 69    ISG 01 70    GTO 05 71    AOFF 72    END

E3/E+ is of course a shortcut for {1 E3, / , 1, +}
ARCLI 01 is a shortcut for {FIX 0, CF 29, ARCL 01, SF 29, FIX 3}

The updated 41Z_Deluxe module - including the ZSAM program in it is now in the DFT posting.

Happy ZSAM'ing folks!

Cheers,
ÁM
 « Next Oldest | Next Newest »

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