Post Reply 
On Convergence Rates of Root-Seeking Methods
03-11-2018, 11:26 PM
Post: #35
RE: On Convergence Rates of Root-Seeking Methods
(03-11-2018 08:41 PM)Mike (Stgt) Wrote:  
(03-11-2018 12:53 PM)Gerson W. Barbosa Wrote:  [...]

0 seconds

If all your routines run within 0 seconds even digits are set to the max and the timer returns only coarse values you may repeat your method 100..1000 times to get some benchmark figures to compare.

0 + something seconds of course, as stated earlier. But that's too vague, I recognize. Around 3 milliseconds @ 2.60 GHz might be closer.

Apparently, the built-in SQR algorithm in Decimal Basic is not optimal:

-----------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH 
LET x = 2
LET s = EXP(LOG(x)/2)
LET t = TIME
FOR i = 1 TO 1000
   LET r = s
   DO 
      LET a = r
      LET b = r*r   
      LET r = (b*(b*(b*(20*x - 5*b + 40) + (120 - 30*x)*x) + x*x*(20*x - 40)) + (8 - 5*x)*x*x*x)/(128*b*b*r)
   LOOP UNTIL ABS(r - a) < 1E-256
NEXT i
PRINT TIME - t;" seconds"
PRINT
PRINT 
END

 3.14  seconds

 Average of 10 runs: 3.013 (min =  2.33; max = 3.25)

-----------------------------------------------------------

OPTION ARITHMETIC DECIMAL_HIGH 
LET x = 2
LET t = TIME
FOR i = 1 TO 1000
   LET r = SQR(x)
NEXT i
PRINT TIME - t;" seconds"
END

  3.87  seconds  

 Average of 10 runs: 3.720 (min =  2.54; max = 4.09)

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


Messages In This Thread



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