Post Reply 
Need help with RPL Listing for "SOLVER FOR ANY VARIABLE"
07-09-2019, 01:37 PM
Post: #8
RE: Need help with RPL Listing for "SOLVER FOR ANY VARIABLE"
(07-09-2019 01:06 AM)Namir Wrote:  Can you plese update the HP48GX (and also the HP-50G) listing to use the maximum number of iterations of 55?????

Your question above indicated 55 for M, but the 71B code used 50. Since my focus is matching the 71B code as much as possible, I used 50.

Rather than maintaining two separate versions, I've made one version which is compatible with the 48GX..50g. That required changing the input routine so that the prompt formatting would be consistent for each of those platforms. I also included radix marks on constants so that approximate (real) numbers would be forced on 49-or-later platforms (again for consistency).

Finally, I changed the ordering of the statements that use PUT in the indefinite loop so that they now follow the same pattern as the others (Line 1: operation, Line 2: STO/PUT). That required an additional command to be added for the PUTs (ROT), but I believe the consistency aids readability more than the cost of a couple extra commands.

Here's what I've got so far:
Code:
%%HP: T(3)A(R)F(.);
\<<
   @ setup local variables
   { 20. } 0. CON                @ X(20)
   4. 1. 1E-7 50.                @ N, K, T, M
   0. DUP DUP DUP                @ F0, X0, H, D
   RCLF                          @ flags
   \-> X N K T M F0 X0 H D flags

   \<<
      @ setup function F
      \<<
         @ X(1)-X(2)*(1+X(3))^X(4)
         X 1. GET
         X 2. GET
         X 3. GET 1. +
         X 4. GET ^
         * -
      \>>
      \-> F

      \<<
         @ obtain X(n) values from user
         0. FIX
         1. N FOR index
            index K SAME "Guess for " "" IFTE
            "X(" +
            index \->STR
            1. OVER SIZE OVER - SUB +
            "):" +
            "" INPUT STR\->
            'X' index ROT PUT
         NEXT

         @ repeat until either:
         @   1) current delta within specified tolerance, or
         @   2) M passes have elapsed
         DO
            X K GET ABS 1. + 0.01 *
            'H' STO

            F EVAL
            'F0' STO

            X K GET
            'X0' STO

            X0 H +
            'X' K ROT PUT

            H F0 * F EVAL F0 - /
            'D' STO

            X0 D -
            'X' K ROT PUT
         UNTIL
            D ABS T \<=
            'M' DECR NOT
            OR
         END

         @ output X(K)
         X K GET "Root" \->TAG

         @ restore flag settings
         flags STOF
      \>>
   \>>
\>>
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Need help with RPL Listing for "SOLVER FOR ANY VARIABLE" - DavidM - 07-09-2019 01:37 PM



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