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 + 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" 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) ----------------------------------------------------------- |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)