Looking for TVM contributions
|
06-20-2024, 04:03 AM
Post: #73
|
|||
|
|||
RE: Looking for TVM contributions
(06-19-2024 09:06 PM)Albert Chan Wrote:(06-19-2024 03:47 PM)robve Wrote: n=480 pv=100000 pmt=-208.333333333333343 fv=0 No. The error is in the i% result. As a consequence the TVM model's parameter space suffers large errors. With previous i% after overshooting the TVM model parameter space isn't badly affected ./tvm 480 '?' 100000 -208.333333333333343 0 1/1 i%= 1e-05 y= 0.00501045666647 2/1 i%= 7.98321085531e-11 y= 3.999917908e-08 3/1 i%= 1.03199085624e-16 y= 2.84217094304e-14 4/1 i%= 6.09287401526e-17 y= 2.84217094304e-14 4, i%=6.0928740152605195e-17% FVerror=1.5e-11 PVerr=1.5e-11 PMTerr=2.8e-14 With last i% after overshooting the TVM model parameters space error is bad: ./tvm 480 '?' 100000 -208.333333333333343 0 1/1 i%= 1e-05 y= 0.00501045666647 2/1 i%= 7.98321085531e-11 y= 3.999917908e-08 3/1 i%= 1.03199085624e-16 y= 2.84217094304e-14 4/1 i%= 6.09287401526e-17 y= 2.84217094304e-14 4, i%=-1.39404957469160446e-17% FVerr=5.4e+05 PVerr=5.4e+05 PMTerr=2.6e+02 Which result should we trust? I am inclined to accept the former over the latter. (06-19-2024 09:06 PM)Albert Chan Wrote:robve Wrote:I'm not completely happy about the iguess() (it's your guess_i() code by the way), which works fine in END mode, but is not as good in BEGIN mode. It also can return an overflow >100% causing NaN. Yes, but for iguess() adjusted for pmt this produces bad initial i% guess for some of the more extreme cases and that worries me. I don't understand why and how an adjustment can be safely made. But I digress since guess_i() is retired (it's quite good actually, except for BEGIN mode and a few other cases). For example, I noticed that adjusting pmt for BGN mode in this case n=40 pv=900 pmt=-400 fv=-1000 gives i%=371.725. Now, this is a hard example so it's not unexpected but still. (06-19-2024 09:06 PM)Albert Chan Wrote:test sample #1 Wrote:./tvm 40 ? 900 -40 -1000 1 With BEGIN mode and the Newton solver: 1/1 i%= 4.55232470519 y= -1.77265084526 2/1 i%= 4.75326326796 y=-0.000915829625612 3/1 i%= 4.75336718854 y=-2.40206077251e-10 4/1 i%= 4.75336718857 y= -7.1054273576e-15 i%=4.75336718857102181% FVerr=1.1e-13 PVerr=0 PMTerr=7.1e-15 After adjusting PV and FV for BEGIN mode there is a sign change because we start at "the wrong side" of the curve but that's no problem: 1/1 i%= 4.75977785174 y= 0.0564948432948 2/1 i%= 4.75336708491 y=-9.13549698112e-07 3/1 i%= 4.75336718857 y= 7.1054273576e-15 4/1 i%= 4.75336718857 y= -7.1054273576e-15 i%=4.75336718857102092% FVerr=2.3e-13 PVerr=0 PMTerr=7.1e-15 Both are equally good. When we have to do one more iteration to get on the right side of the curve, then that isn't a big deal. 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. - Rob "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 14 Guest(s)