Post Reply 
(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
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
- enter a guess, start with R/S

By the way, I have also tried a Regula Falsi / Illinois version for the 12C. This is slightly more effort as the 12C does not support subroutines and there are three different cases (as opposed to two for Newton) that have to be handled by the code that accepts the return value of the function call. But it is possible – in 70 steps.

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Newton's Method - Gamo - 03-24-2018, 01:10 PM
RE: (12C) Newton's Method - Dieter - 03-24-2018 01:31 PM
RE: (12C) Newton's Method - Dieter - 03-27-2018, 06:08 PM
RE: (12C) Newton's Method - Gamo - 03-25-2018, 03:05 AM
RE: (12C) Newton's Method - Dieter - 03-25-2018, 06:26 PM
RE: (12C) Newton's Method - Gamo - 03-28-2018, 04:23 AM
RE: (12C) Newton's Method - Carsen - 03-29-2018, 05:11 AM
RE: (12C) Newton's Method - Dieter - 03-29-2018, 05:04 PM
RE: (12C) Newton's Method - Gene - 03-29-2018, 05:23 PM
RE: (12C) Newton's Method - Gamo - 03-30-2018, 01:15 PM
RE: (12C) Newton's Method - Dieter - 03-30-2018, 02:00 PM
RE: (12C) Newton's Method - Gamo - 03-31-2018, 01:15 PM
RE: (12C) Newton's Method - Dieter - 03-31-2018, 05:27 PM



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