Post Reply 
Newton Method
05-11-2016, 08:40 PM (This post was last modified: 05-11-2016 08:49 PM by Dieter.)
Post: #2
RE: Newton Method
(05-11-2016 07:54 PM)bshoring Wrote:  Can anyone point me to any examples of the Newton or Newton-Raphson method for solving f(x)=0 ? I'm looking for something that can run on the early HP programmables, like the HP-65 or 67.

That's quite straightforward. Here is a short example that I just tried (slightly modified) on the 34s. It's not elegant, but it does its job. It should run on the 67/97 as well as the 65 (with some steps unmerged). The key is the evaluation of f'(x) which is calculated via [f(x+h) – f(x)]/h where h is x/10000 (resp. 1/10000 if x=0).

Code:
001 LBL A
002 STO 0   ' x
003 LBL 1
004 RCL 0
005 GSB E
006 STO 1   ' store f(x)
007 RCL 0
008 x=0?
009 e^x     ' turn x = 0 into 1
010 EEX
011 4
012 /
013 STO 2   ' store h = x/10000
014 RCL 0
015 +
016 GSB E   ' get f(x+h)
017 RCL 1
018 -       ' f(x+h) - f(x)
019 RCL 2
020 /       ' ... / h ~= f'(x)
021 RCL 1
022 x<>y
023 /       ' f(x) / f'(x)
024 STO- 0  ' adjust x
025 RCL 0
026 R/S     ' show new x
027 GTO 1   ' next iteration

028 LBL E
... your
... f(x)
... here
... RTN

R0: x
R1: f(x)
R2: h

Place your f(x) code at label E. The argument x is expected in the X-register.

Example: f(x) = x^3 – x^2 – x + 0,5

Using Horner's method this can be coded as

Code:
LBL E
ENTER
ENTER
ENTER
1
-
x
1
-
x
,
5
+
RTN

Enter your first guess for a root of f(x) and press A.
Starting at x=0, this is what you get in FIX 6:

Code:
0 [A] => 0,499995

[R/S] => 0,400000

[R/S] => 0,403030

[R/S] => 0,403032

[R/S] => 0,403032

Pressing [x<>y] shows the last correction term, i.e. an estimate for the accuracy of the current approximation.

The other two roots of this function can be found starting at x=—1 resp. x=2.

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


Messages In This Thread
Newton Method - bshoring - 05-11-2016, 07:54 PM
RE: Newton Method - Dieter - 05-11-2016 08:40 PM
RE: Newton Method - Namir - 05-12-2016, 08:47 PM
RE: Newton Method - Dieter - 05-12-2016, 09:17 PM
RE: Newton Method - Namir - 05-13-2016, 01:59 PM
RE: Newton Method - bshoring - 05-14-2016, 07:49 PM
RE: Newton Method - Dieter - 05-14-2016, 10:23 PM
RE: Newton Method - Namir - 05-15-2016, 02:00 AM
RE: Newton Method - Dieter - 05-15-2016, 01:11 PM
RE: Newton Method - Namir - 05-15-2016, 01:57 PM
RE: Newton Method - bshoring - 05-12-2016, 12:10 AM
RE: Newton Method - bshoring - 05-14-2016, 06:36 AM
RE: Newton Method - SlideRule - 08-24-2016, 12:08 PM
RE: Newton Method - Pekis - 08-24-2016, 12:20 PM
RE: Newton Method - Csaba Tizedes - 08-24-2016, 08:37 PM
RE: Newton Method - Duane Hess - 08-25-2016, 04:47 AM
RE: Newton Method - Namir - 08-25-2016, 05:00 AM
RE: Newton Method - rprosperi - 08-25-2016, 04:19 PM
RE: Newton Method - bshoring - 08-27-2016, 03:09 AM
RE: Newton Method - Duane Hess - 08-27-2016, 06:31 AM
RE: Newton Method - SlideRule - 08-28-2016, 02:57 AM
RE: Newton Method - rprosperi - 08-29-2016, 12:46 AM



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