Looking for TVM contributions
|
06-20-2024, 03:07 PM
Post: #74
|
|||
|
|||
RE: Looking for TVM contributions
(06-20-2024 04:03 AM)robve Wrote: With last i% after overshooting the TVM model parameters space error is bad: Because f(ε) was not implemented, y3 and y4 almost the same. Bad y/y' cause extrapolated i% go crazy, even its sign is wrong. f(ε) part is a 1-liner. I think it is worth adding. 40 DEF FNF(I) @ IF N*I*I+1-1 THEN FNF=((P+F)/EXPM1(LOGP1(I)*N)+P)*I+M @ END 50 Z=P+F @ FNF=(Z+N*M+I*((Z+N*(P-F))/2+I*Z*(N*N-1)/12))/N @ END DEF But bad i does not explain huge errors. How are they calculated? lua> i = -1.3940495746916044e-19 lua> NFV(480, i, 1e5, -208.333333333333343, 0) 0 lua> NPV(480, i, 1e5, -208.333333333333343, 0) 0 lua> npmt(480, i, 1e5, -208.333333333333343, 0) 0 robve Wrote:iguess() adjusted for pmt this produces bad initial i% guess for some of the more extreme cases and that worries me ... guess_i() assumed (n*i) is small, and NPMT is quadratic of rate. Above example, if we solve actual quadratic, we have imaginary numbers. Pade approx was used to return real guess, even if quadratic have no real root. BTW, why is i% > 100 a problem? I just tried 1 billion %, and it run OK (next iteration ≈ edge rate, as expected) lua> tvm_begin(40, 1e7, 900, -400, -1000, true) Code: 1e+07 4999999600 500 robve Wrote:About the npmt curvature: adjusting npmt for positive f'' is just a sign change of npmt. But root finders don't need to care as we know, because they flip to the other side of the curve anyway (as shown above). Theoretically then they never need to flip back again unless f'' changes sign. For TVM f'' won't change sign I believe, but numerically there is a nonzero possibility that the sign of npmt may flip close to root due to inaccuracies, especially with lower precision solvers. That worries me. Problem is in Secant's method. We are estimating slope with points, which may not be both on the outside. Depends on where they are, we don't know how many iterations until *both points* moved outside. Hybrid work better perhaps is due to this. It moved next point to the outside, on the first try. Switch back to Secant with both points outside, give us nice one-sided convergence. (04-09-2022 05:47 PM)Albert Chan Wrote: \(\displaystyle I ≈ \frac{1}{P} - \frac{P}{N^2}\) find_rate() thus skip over user-supplied guess, and consider next one as initial guess. Below example, the better guess is on the inside ... Newton pushed it out. lua> n,pv,pmt,fv = 365*24*60*60,0,-0.01,331667.0067 -- problem 3 lua> i = pmt/fv lua> i -- edge rate -3.015072285753529e-08 lua> find_rate(n, i-1/i/n^2, pv, pmt, fv, true) -- perhaps better guess Code: 3.1987564370323693e-09 -4.4522291350098525e-06 -160259.18297182902 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)