Third Order Convergence for Reciprocal
|
09-19-2021, 05:59 PM
Post: #3
|
|||
|
|||
RE: Third Order Convergence for Reciprocal
This version use a trick from thread Fun Math Algorithm.
(09-08-2020 09:59 PM)Albert Chan Wrote: We can reduce summing terms, from O(n), to O(ln(n)) Unlike Newton's or Halley's, sum is not self-correcting. Instead, we add 1 at the very end. 1/(1-ε) - 1 = (ε+ε²) + ε²(ε+ε²) + ε4[(ε+ε²) + ε²(ε+ε²)] + ... Code: function rcp2(x, verbose) Convergence is 2nd-order (this use 2 mul + 1 add per loop, slightly less costly than Newton's) To speed up convergence, mantissa [1/2, 1) → [2/3, 4/3), thus |ε| ≤ 1/3 lua> r = rcp2(1/2, true) -- mantissa shifted to 1 2 lua> r = rcp2(5/8, true) -- mantissa shifted to 5/4 1.625 1.6015625 1.600006103515625 1.6000000000931323 1.6 lua> r = rcp2(7/8, true) 1.140625 1.142822265625 1.1428571343421936 1.1428571428571423 1.1428571428571428 lua> r = rcp2(1-1e-16, true) 1 |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
Third Order Convergence for Reciprocal - Albert Chan - 09-19-2021, 04:14 PM
RE: Third Order Convergence for Reciprocal - Albert Chan - 09-19-2021, 04:47 PM
RE: Third Order Convergence for Reciprocal - Albert Chan - 09-19-2021 05:59 PM
RE: Third Order Convergence for Reciprocal - lyuka - 09-20-2021, 04:33 AM
RE: Third Order Convergence for Reciprocal - Albert Chan - 09-20-2021, 01:20 PM
RE: Third Order Convergence for Reciprocal - ttw - 09-20-2021, 10:14 AM
RE: Third Order Convergence for Reciprocal - Albert Chan - 09-22-2021, 10:32 AM
RE: Third Order Convergence for Reciprocal - Namir - 09-25-2021, 09:39 PM
|
User(s) browsing this thread: 4 Guest(s)