# HP Forums

Full Version: Recommend root-finder for HP 67
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
I don't particularly like the root finder from the HP 67 standard pac. I have to insert the program lines into the other code, and it gets stuck frequently it seems. Do you have a simple end elegant root finder that you would recommend? Thanks!
Here is the code for Newton's method for the HP-67:

Code:
```Memory Map ============ R0 = Torelance R1 = x R2 = h R3 = fx(x) Listing ======= LBL A STO 1    # Store x RDN STO 0    # Store tolerance LBL 0    # start iteration loop RCL 1 PAUSE     # View curent guess for root ABS 1 + EEX 2 CHS * STO 2     # Store h RCL 1 GSB E     # calculate fx(x) STO 3 RCL 1 RCL 2 + GSB E     # calculate fx(x+h) RCL 3 - 1/X RCL 3 * RCL 2 *         # Calculate difference STO- 1    # X = X - difference ABS RCL 0 X<=Y?     # |difference| >= tolerance? GTO 0     # resume iteration RCL 1     # display x RTN LBL E     # define f(x) EXP LASTX X^2 3 * - RTN```

Load the above program. Edit the code in LBL E to implement the function you want to find the root for. Then:

1) Enter the tolerance value.
2) Press Enter.
3) Enter the guess for the root.
4) Press the A key.
5) The program will display the intermediate guesses for the solution using a PAUSE statement. Then the program displays the refined guess for the root, based on the tolerance value supplied.

You can calculate fx(x) values by entering a value for x and then pressing the E key.
(11-30-2019 03:08 AM)Namir Wrote: [ -> ]Here is the code for Newton's method for the HP-67:

Code:
```Memory Map ============ R0 = Torelance R1 = x R2 = h R3 = fx(x) Listing ======= LBL A STO 1    # Store x RDN STO 0    # Store tolerance LBL 0    # start iteration loop RCL 1 PAUSE     # View curent guess for root ABS 1 + EEX 2 CHS * STO 2     # Store h RCL 1 GSB E     # calculate fx(x) STO 3 RCL 1 RCL 2 + GSB E     # calculate fx(x+h) RCL 3 - 1/X RCL 3 * RCL 2 *         # Calculate difference STO- 1    # X = X - difference ABS RCL 0 X<=Y?     # |difference| >= tolerance? GTO 0     # resume iteration RCL 1     # display x RTN LBL E     # define f(x) EXP LASTX X^2 3 * - RTN```

Load the above program. Edit the code in LBL E to implement the function you want to find the root for. Then:

1) Enter the tolerance value.
2) Press Enter.
3) Enter the guess for the root.
4) Press the A key.
5) The program will display the intermediate guesses for the solution using a PAUSE statement. Then the program displays the refined guess for the root, based on the tolerance value supplied.

You can calculate fx(x) values by entering a value for x and then pressing the E key.

Thanks! I am looking in vain for "RDN", do you mean "RND"?
EDIT: ah, I guess it's "roll down"

EDIT2: and "EXP" would be yX right?

EDIT3: What needs to remain in "E"? Should it always start with LASTX, and then put my function behind that?
EXP is e^X.

LBL E ia the label you use to code f(x)=0. In my example, f(x)=e^x-3*x^2. You can start the code for f(x) by storing the value of x in an unused register, so you can reuse it to calculate x. I chose LASTX is recall X after calculate e^x.

Namir
(11-30-2019 06:14 AM)Namir Wrote: [ -> ]EXP is e^X.

LBL E ia the label you use to code f(x)=0. In my example, f(x)=e^x-3*x^2. You can start the code for f(x) by storing the value of x in an unused register, so you can reuse it to calculate x. I chose LASTX is recall X after calculate e^x.

Namir

Ah that makes sense. Sorry, I was a bit tired yesterday. And it works! Thank you very much!
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :