Post Reply 
Using FROOT recursively on the HP-71?
02-05-2017, 08:48 AM (This post was last modified: 02-05-2017 08:55 AM by Ángel Martin.)
Post: #8
RE: Using FROOT recursively on the HP-71?
Progress made at last - ignore the previous fumbling if you must, here's the real thing:

The key is how the functions are defined, whereby the first function forces repeated root searching of the second until both functions are satisfied. This needs to be translated to the 41 register-based memory scheme playing carefully with the definitions.

Let's use the same example from Valentin's article:
f(x,y) = x^2 + y^2 - 5
g(x,y) = x^2 - y^2 - 3

We'll use g(x,y) as the "slave" equation, and f(x,y) the "master" function - meaning that for each guess Xo we'll FIRST get the root Yo for g(Xo, y), and use that root as the companion guess "Yo" (never mind my colorful nomenclature). This we'll repeat until the pair (Xo, Yo) is a root for f as well as for g.

How to translate this to a FOCAL environment? Here we go...
  1. The Function to solve for Xo is *not* f(x,y), but f(x, Yo) - now, this was all the time before my eyes in Valentin's article but took me a while to realize how to adapt it here; which is accomplished by carefully defining both f(x,y) and g(x,y)
  2. The definition of g(x,y) must assume X constant in R00, whilst Y is given in the stack (per SOLVE's conventions). Then after the Yo root value is obtained, we need a call to f(x,Yo) within the nested function to "shape" it according to the master rule.
  3. Thus it follows that the definition of f(x,y) should use X in R00 and Y in R01.

The code is shown below. The nested function LBL "*FG" is the secret sauce of the recipe:

Code:
01   LBL "FRT2"   LBL "FF"
02   CLKEYS       RCL 00
03   STO 05       X^2
04   RDN          RCL 01
05   STO 04       X^2
06   RDN          +
07   STO 03       5
08   RDN          -
09   STO 02       RTN
10   13           LBL "GG"
11   BUF?         STO 01
12   DELBUF       RCL 00
13   RCL 02       X^2
14   RCL 03       RCL 01
15   "*FG"        X^2
16   FROOT        -
17   RTN          3
18   LBL "*FG"    -
19   STO 00       END
20   14,013    
21   REIDBF    
22   RCL 04    
23   RCL 05    
24   "GG"    
25   FROOT    
26   13.014    
27   REIDBF    
28   RDN    
29   XEQ "FF"    
30   END


That's it, next step is the refining for a general-purpose case using routine names in ALPHA instead of hard-coded strings for LBL FF and LBL GG. Will post a proper article when it's ready to go - thanks again and sorry about the fumbling digressions ;-)

Best,
ÁM

"To live or die by your own sword one must first learn to wield it aptly."
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Using FROOT recursively on the HP-71? - Ángel Martin - 02-05-2017 08:48 AM



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