Looking for TVM contributions
|
06-15-2024, 02:36 PM
Post: #48
|
|||
|
|||
RE: Looking for TVM contributions
Hi, robve
I think Newton's vs Secant's is just like integrate using Double-Exp vs Romberg. Double-Exp integrate amazingly fast, using very few points, but required good f Newton's method, with a single point, f and f' need to be accurate. We only need accurate f/f', but I don't know how to get that without good f, f'. Code: npmt = k*pmt - (pv + fv*s)*j/r; // k=1+j*b, s=(1+j)^-n, r=s-1 pv and fv normally are big, likely opposite sign, (pv+fv*s) may have cancellation issue. But, (pv+fv), (pv-fv), (pv+pmt), (fv-pmt) probably OK k = 1+j*b, for b=1, also may lose precision. npmt = (1+j*b)*pmt - (pv + fv*(r+1))*j/r = pmt + j*b*pmt - j*fv - (pv+fv)*j/r npmt = (-(pv+fv)/r - (fv-b*pmt))*j + pmt npmt' = -(pv+fv)/r*(1+n*(r+1)/(r+r/j)) - (fv-b*pmt) Or, if you prefer, its time-symmetric version, where R = subst(r, n=-n) This setup coded for HP71B (with test samples), and seems to work well. npmt = ((pv+fv)/R + (pv+b*pmt))*j + pmt npmt' = (pv+fv)/R*(1-n*(R+1)/(R+R/j)) + (pv+b*pmt) BTW, I would not do {j = 0.01*i; ...; i=100*j} for binary code. I would do everything in j. If % is needed, simply multply by 100. Sorry for the broken record, code need a branch to handle tiny rate! Without that, edge guess is not safe to use. A hard coded guess rate is not ideal. I remember Plus42 had hard coded i = 0.0001 Looking at the code, it is easy to make a situation where this would fail TVM solver. This is why edge rate were later used, and user cannot supply their own guess. Perhaps this hand holding is overkill, but it does make rate search robust. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 10 Guest(s)