Looking for TVM contributions
|
06-19-2024, 03:40 PM
(This post was last modified: 06-19-2024 03:51 PM by Albert Chan.)
Post: #68
|
|||
|
|||
RE: Looking for TVM contributions
(06-19-2024 12:20 PM)Albert Chan Wrote: asymptote line slope is more extreme (in size) than at any other point, Here is a trick that work with any rate guess, and have one-sided convergence. lua> n,pv,pmt,fv = 10,50,-30,80 -- sample #23 lua> f = fn'x: npmt(n,x,pv,pmt,fv)' lua> i = 0.01 -- any guess OK lua> X = -pv -- go for big root lua> for k=1,5 do eps=f(i)/X; i=i+eps; print(i, eps) end 0.3514866009669545 0.3414866009669545 0.5527206785990931 0.20123407763213863 0.5821388175291544 0.029418138930061274 0.5844404930347874 0.002301675505633014 0.5846067021783057 0.0001662091435182589 We can speed up convergence, with smaller slope. What is the ideal slope? We assume constant rate of convergence. lua> r = 0.0001662091435182589 / 0.002301675505633014 lua> X = X * (1-r) lua> for k=1,5 do eps=f(i)/X; i=i+eps; print(i, eps) end 0.5846195592477864 1.2857069480758773e-05 0.5846195526588186 -6.588967862434568e-09 0.5846195526622116 3.3930050292746237e-12 0.5846195526622099 -1.6848616523122454e-15 0.5846195526622099 -0 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)