Post Reply 
(12C) Numeric Solver
04-13-2017, 01:50 AM
Post: #1
(12C) Numeric Solver
This solver uses Newton's method to solve f(x)=0. It is an adaptation of the HP-25 solver (HP-25 Application Programs, Chapter 5). The program uses registers 0, 1, 2, 3 and 4.

Enter the program as listed- it will occupy lines 1 through 38. The formula to be solved will start on line 39 and must end with the command GTO 17.

EXAMPLE-

Solve ln x + 3x -10.8074 = 0

Starting with line 38 displayed, enter the formula:

LN
LST X
3
*
+
1
0
.
8
0
7
4
-
GTO 17

Store an initial guess in register 1:

1
STO 1

Store the desired tolerance in register 2:

EEX
5
CHS
STO 2

Press R/S to solve. Result: 3.21336

PHP Code:
CLX    
STO 0    
RCL 1    
GTO 39    
//xeq formula
ROLL DN    
STO 4    
1    
STO 0    
RCL 1    
RCL 1    
EEX    
5    
/    
STO 3    
+    
GTO 39    //xeq formula
X=0    
GTO 37    
RCL 0    
X
=0    
GTO 05    
ROLL DN    
RCL 4    
/    
1    
-    
1/X    
RCL 3    
x     
STO – 1    
2    
Y
^X    
SQRT    
RCL 2    
X
<=Y       //x is less than or equal to y    
GTO 01    
RCL 1    
//answer
R/S    
            
//formula...
GT0 17 
Find all posts by this user
Quote this message in a reply
04-14-2017, 04:33 PM (This post was last modified: 04-14-2017 04:33 PM by Dieter.)
Post: #2
RE: (12C) Numeric Solver
(04-13-2017 01:50 AM)Dwight Sturrock Wrote:  This solver uses Newton's method to solve f(x)=0. It is an adaptation of the HP-25 solver (HP-25 Application Programs, Chapter 5).

The program calculates h (in R3) as x/1E5. This does not work for x=0 since it yields h=0 and so the derivative gets zero, leading to a division by zero.

But this can be fixed easily:

...
RCL 1
RCL 1
X=0?
e^x

EEX
4
/
STO 3
...

After this change the GTOs of course need to be updated.

One more tip: instead of 2 [Y^X] always use [ENTER] [x]. This is much faster and exact.

Dieter
Find all posts by this user
Quote this message in a reply
04-14-2017, 10:15 PM
Post: #3
RE: (12C) Numeric Solver
(04-14-2017 04:33 PM)Dieter Wrote:  
(04-13-2017 01:50 AM)Dwight Sturrock Wrote:  This solver uses Newton's method to solve f(x)=0. It is an adaptation of the HP-25 solver (HP-25 Application Programs, Chapter 5).

The program calculates h (in R3) as x/1E5. This does not work for x=0 since it yields h=0 and so the derivative gets zero, leading to a division by zero.

But this can be fixed easily:

...
RCL 1
RCL 1
X=0?
e^x

EEX
4
/
STO 3
...

After this change the GTOs of course need to be updated.

One more tip: instead of 2 [Y^X] always use [ENTER] [x]. This is much faster and exact.

Dieter

Thanks Dieter, I'll try your enhancements and repost.
Find all posts by this user
Quote this message in a reply
Post Reply 




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