Post Reply 
Third Order Convergence for Square Roots Using Newton's Method
09-16-2021, 07:45 PM (This post was last modified: 09-16-2021 07:48 PM by C.Ret.)
Post: #11
RE: Third Order Convergence for Square Roots Using Newton's Method
(08-28-2019 07:32 PM)bshoring Wrote:  Could we have an example of this in RPN, say for HP-67?

You are welcome.

Here is a code with three sub-routines that compute square root using the first three methods respectively:
  1. The second order converging algorithm indicated by Namir aka the Héron method:
    \( x_{k+1} = \frac{x_i + \frac{N}{x_k}}{2} \)
  2. The third order converging algorithm Namir stumbled on :
    \( x_{k+1} = x_n \frac{x_k^2+ 3.N}{3.x_k^2+N} \)
  3. The Halley's formula proposed by Albert Chan:
    \( x_{k+1}=x_n-\frac{2.x_k.(x_k^2−N)}{3.x_k^2+N} \)




Code:
001   31 25 11  f LBL A      010   31 25 12  f LBL B      024   31 25 13  f LBL C
002      34 00    RCL 0      011      33 01    STO 1      025      33 01    STO 1     
003      35 52  h x:y        012   33 71 01    STO×1      026   33 71 01    STO×1        
004         81     ÷         013      34 01    RCL 1      027      34 01    RCL 1
005      35 82  h LSTx       014         03     3         028         02     2
006         61     +         015   33 71 01    STO×1      029   33 71 01    STO×1
007         02     2         016      34 00    RCL 0      030      35 52  h x:y
008         81     ÷         017   33 61 01    STO+1      031   33 61 01    STO+1
009      35 22  h RTN        018         71     ×         032      34 00    RCL 0
                             019         61     +         033   33 61 01    STO+1
                             020      34 01    RCL 1      034         51     - 
                             021         81     ÷         035         71     × 
                             022         71     ×         036         71     ×
                             023      35 22  h RTN        037      34 01    RCL 1
                                                          038         81     ÷
                                                          039         51     -
                                                          040      35 22  h RTN

These programs only run one step of each method. The value n for the expected square root have to be store in register R0 and the first guest or estimate has to be set in register X: of the stack. Each press on A, B or C key affine the estimation displayed in register X: by one step using the corresponding method.

For example :
51 STO 0
7 A display 7.142857145
Further press on A display 7.141428570, 7.141428430, 7.141428430, ...

where
7 B, B, B, ... successively display 7.141414140, 7.141428423, ...

and
7 C, C, C, ... successively display 7.141414141, 7.141428429, 7.141428428, ...
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Third Order Convergence for Square Roots Using Newton's Method - C.Ret - 09-16-2021 07:45 PM



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