Post Reply 
New Root-Seeking Algorithms
04-05-2017, 09:47 PM
Post: #15
RE: New Root-Seeking Algorithms
Hi Namir,

here is an HP-41 program that uses quadratic interpolation to find a root of f(x) = 0

It takes 3 guesses in registers X Y Z and returns a root x in X-register and f(x) in Y-register ( which should be a "small" number ) if flag F02 is clear.
It should also find double roots.

If F02 is set, "SLV2" tries to find an extremum.

In both cases, R00 = function name is to be initialized.

Here is the listing:

01 LBL "SLV2"
02 STO 01
03 RDN
04 STO 02
05 X<>Y
06 STO 03
07 XEQ IND 00
08 STO 06
09 RCL 02
10 XEQ IND 00
11 STO 05
12 LBL 01
13 VIEW 01
14 RCL 01
15 XEQ IND 00
16 STO 04
17 RCL 02
18 RCL 03
19 -
20 *
21 ENTER
22 STO 07
23 RCL 01
24 RCL 03
25 -
26 STO 08
27 STO 10
28 ST* Z
29 RCL 05
30 *
31 ST* 08
32 -
33 RCL 02
34 RCL 01
35 -
36 STO 09
37 ST- 10
38 ST* Z
39 RCL 06
40 *
41 ST* 09
42 -
43 STO 06
44 *
45 RCL 07
46 RCL 10
47 *
48 RCL 08
49 -
50 RCL 09
51 +
52 2
53 /
54 STO 10
55 X^2
56 +
57 FC? 02
58 X<0?
59 GTO 02
60 SQRT
61 RCL 10
62 SIGN
63 *
64 RCL 10
65 +
66 GTO 03
67 LBL 02
68 RCL 10
69 CHS
70 RCL 06
71 LBL 03
72 X#0?
73 /
74 RCL 01
75 +
76 X<> 01
77 X<> 02
78 STO 03
79 RCL 04
80 X<> 05
81 STO 06
82 RCL 01
83 RCL 02
84 X#Y?
85 GTO 01
86 RCL 04
87 X<>Y
88 END

( 113 bytes / SIZE 011 )

Number of function evaluations = 2 + number of iterations.

Best wishes,
JM.
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
New Root-Seeking Algorithms - Namir - 04-02-2017, 09:28 PM
RE: New Root-Seeking Algorithms - pier4r - 04-02-2017, 09:54 PM
RE: New Root-Seeking Algorithms - Namir - 04-02-2017, 11:12 PM
RE: New Root-Seeking Algorithms - Namir - 04-02-2017, 11:15 PM
RE: New Root-Seeking Algorithms - bshoring - 04-03-2017, 09:23 PM
RE: New Root-Seeking Algorithms - Namir - 04-04-2017, 10:11 AM
RE: New Root-Seeking Algorithms - emece67 - 04-04-2017, 08:43 AM
RE: New Root-Seeking Algorithms - Namir - 04-04-2017, 01:13 PM
RE: New Root-Seeking Algorithms - ttw - 04-04-2017, 09:22 AM
RE: New Root-Seeking Algorithms - pier4r - 04-04-2017, 09:33 AM
RE: New Root-Seeking Algorithms - Namir - 04-04-2017, 10:14 AM
RE: New Root-Seeking Algorithms - ttw - 04-04-2017, 02:20 PM
RE: New Root-Seeking Algorithms - emece67 - 04-04-2017, 02:39 PM
RE: New Root-Seeking Algorithms - JMBaillard - 04-05-2017 09:47 PM
RE: New Root-Seeking Algorithms - Namir - 04-05-2017, 10:00 PM
RE: New Root-Seeking Algorithms - ttw - 04-06-2017, 01:51 AM
RE: New Root-Seeking Algorithms - Namir - 04-06-2017, 03:17 AM
RE: New Root-Seeking Algorithms - DMaier - 04-06-2017, 05:11 AM
RE: New Root-Seeking Algorithms - Namir - 04-06-2017, 09:05 AM
RE: New Root-Seeking Algorithms - ttw - 04-09-2017, 09:33 PM
RE: New Root-Seeking Algorithms - Namir - 04-10-2017, 05:01 AM
RE: New Root-Seeking Algorithms - Namir - 04-13-2017, 01:23 PM
RE: New Root-Seeking Algorithms - Namir - 04-15-2017, 10:58 PM
RE: New Root-Seeking Algorithms - robve - 11-25-2020, 09:44 PM
RE: New Root-Seeking Algorithms - Namir - 04-16-2017, 01:06 PM
RE: New Root-Seeking Algorithms - ttw - 04-20-2017, 05:05 AM



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