(12C) Newton's Method
03-24-2018, 01:31 PM (This post was last modified: 03-24-2018 07:30 PM by Dieter.)
Post: #2
 Dieter Senior Member Posts: 2,398 Joined: Dec 2013
RE: (12C) Newton's Method
(03-24-2018 01:10 PM)Gamo Wrote:  This is a very good all around Solver for HP-12C and this one work very well.

...if you remove line 33. ;-)

The sequence 2 ENTER x SQRT does not make sense, this always yields 2. Remove the line with the "2" and the program should work as intended (compare the absolute value of the last correction term with the tolerance in R2). This also means that all references to line 42 should be changed to line 41.

There is an error in the instructions for the example: the tolerance has to be stored in R2. So it's EEX 6 CHS STO 2.
I think you should also mention that x^x=y here is transformed to x · ln x – ln y = 0, which is how the function is coded.

The program may have an error in that it stops the iteration not only if f(x)=0 but also if f(x+h)=0. OK. this can be fixed easily.
And maybe the final step should better be GTO 00 instead of R/S so that the program can be restarted with a simple R/S.
Here is my attempt at a corrected version:

Code:
01 STO 1 02 1 03 STO 0 04 RCL 1 05 GTO 42 06 RCL 0 07 x=0? 08 GTO 25 09 Rv 10 STO 4 11 x=0? 12 GTO 40 13 0 14 STO 0 15 RCL 1 16 x=0? 17 e^x 18 EEX 19 4 20 / 21 STO 3 22 RCL 1 23 + 24 GTO 42 25 Rv 26 RCL 4 27 - 28 RCL 3 29 / 30 RCL 4 31 x<>y 32 / 33 STO-1 34 ENTER 35 x 36 SQRT 37 RCL 2 38 x<=y? 39 GTO 02 40 RCL 1 41 GTO 00 42 .       start f(x) here    .    .    . nn GTO 06  end with this line

- store the tolerance in R2