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. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)