Post Reply 
(HP71B) Newton's method
11-13-2024, 08:38 PM (This post was last modified: 11-18-2024 02:28 PM by Albert Chan.)
Post: #7
RE: (HP71B) Newton's method
(11-12-2024 12:12 PM)Albert Chan Wrote:  I think interval (x ± h), h based from previous correction is better.
This version also showed details about when old slope was reused (when count increase by 3)

It may be better to count correction using old slope (LINE 70) as separate iteration.
In other words, count increase by 1 if old slope was reused.

For same epsilon, this would likely quit earlier, not wasting iterations.

1 DESTROY ALL @ C=0
2 DEF FNF(X)=EXP(X)-3*X*X
3 INPUT "Guess, Accuracy = ";X,A @ D=X+(X=0)
10 FOR I=1 TO 30 @ H=ABS(.01*D)
20 F1=FNF(X-H) @ F2=FNF(X+H)
30 R=2*H/(F2-F1) ! reciprocal slope
40 D=(F1+F2)/2*R ! secant root = X-D
50 C=C+2 @ X=X-D @ DISP X,D,C @ IF ABS(D)<=A THEN EXIT I
60 IF ABS(D)>H THEN 80
70 D=FNF(X)*R @ C=C+1 @ X=X-D @ DISP X,D,C @ IF ABS(D)<=A THEN EXIT I
80 NEXT I

Code:
Guess, Accuracy = 3, 1e-6
 6.30761737624       -3.30761737624        2
 5.46675063672        .840866739517        4
 4.74557560076        .72117503596         6
 4.19690889791        .54866670285         8
 3.86665484877        .330254049138        10
 3.74748651079        .119168337984        12
 3.73326631876        1.42201920313E-2     14
 3.73307904233        1.8727643326E-4      16
 3.73307902863        1.36971908949E-8     18
Code:
Guess, Accuracy = 4, 1e-6
 3.78319350935        .216806490652        2
 3.7352742822         4.79192271496E-2     4
 3.7330832523         2.19102989768E-3     6
 3.73307902821        4.22409335906E-6     8
 3.73307902863       -4.17325436225E-10    9



Previous post with straightened curve

>2 DEF FNF(X)= 1 - 3*X^2/EXP(X)

Code:
Guess, Accuracy = 3, 1e-6
 3.76823887888       -.768238878882        2
 3.73298203526        3.52568436176E-2     4
 3.73307903755       -9.70022880736E-5     6
 3.73307902863        8.91748978705E-9     7
Code:
Guess, Accuracy = 4, 1e-6
 3.7252587096         .274741290395        2
 3.73307492918       -7.81621958153E-3     4
 3.7330790291        -4.0999245281E-6      6
 3.73307902863        4.69575066737E-10    7
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(HP71B) Newton's method - Albert Chan - 10-01-2023, 03:59 PM
RE: (HP71B) Newton's method - Albert Chan - 10-01-2023, 04:34 PM
RE: (HP71B) Newton's method - Albert Chan - 10-01-2023, 09:47 PM
RE: (HP71B) Newton's method - Albert Chan - 10-02-2023, 04:04 PM
RE: (HP71B) Newton's method - Albert Chan - 11-12-2024, 12:12 PM
RE: (HP71B) Newton's method - Albert Chan - 11-13-2024, 01:12 PM
RE: (HP71B) Newton's method - Albert Chan - 11-13-2024 08:38 PM
RE: (HP71B) Newton's method - Albert Chan - 11-18-2024, 01:22 PM
RE: (HP71B) Newton's method - Albert Chan - 11-21-2024, 12:08 AM



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