Looking for TVM contributions
|
06-18-2024, 03:27 AM
Post: #60
|
|||
|
|||
RE: Looking for TVM contributions
(06-17-2024 09:03 PM)robve Wrote: Assuming TYPE is 0 for END and 1 for BGN, then we recognize PV and FV are switched and their signs inverted and N is inverted: This way we can control the error in npmt() and optimize the result, which Albert mentioned before i.e. "time reversal". Lets call this the forward npmt(): j = 0.01*i; k = 1.0 + j*b; l = log1p(j); r = expm1(-n*l); s = r + 1.0; return k*pmt - (pv + fv*s)*j/r; The backward dual npmt() is: j = 0.01*i; k = 1.0 + j*b; l = log1p(j); r = expm1(n*l); s = r + 1.0; return k*pmt + (fv + pv*s)*j/r; The npmt() version to pick to solve the rate depends on the values of s and r that we get. My thought on this is that we should pick the version in which |s| and |r| are relatively close. Let me illustrate with the "time reversed" TVM problem, which is essentially the same. The forward npmt() is best for this TVM example (the backward npmt() line is fatter): ./tvm 5 '?' -369494.09 17500 540000 3/0 i%= 11.9999997132 y=-2.05654941965e-08 4/0 i%= 11.9999997132 y= 0 4, 11.9999997132285614%, 0 s=0.567426862982966185 r=-0.43257313701703376 ./tvm -5 '?' -540000 17500 369494.09 3/0 i%= 11.9999997132 y=-2.05764081329e-08 4/0 i%= 11.9999997132 y=-7.27595761418e-12 5/0 i%= 11.9999997132 y= 2.91038304567e-11 5, 11.9999997132285596%, 0 s=1.76234166063797959 r=0.762341660637979479 The |s| and |r| values are closer in the forward than in the backward npmt(). Another TVM example: ./tvm 328 '?' 35000 -324 0 3/0 i%= 0.87205693754 y= 6.9640698257e-06 4/0 i%= 0.872056914834 y= 1.54045665113e-11 5/0 i%= 0.872056914834 y= 5.68434188608e-14 6/0 i%= 0.872056914834 y=-5.68434188608e-14 6, 0.872056914834067998%, 1.3e-10 s=0.0579632092841858571 r=-0.942036790715814143 ./tvm -328 '?' 0 -324 -35000 3/0 i%= 0.87205693754 y= 6.96406976886e-06 4/0 i%= 0.872056914834 y= 1.54614099301e-11 5/0 i%= 0.872056914834 y= 0 5, 0.872056914834067887%, 0 s=17.2523228501226313 r=16.2523228501226313 Because we don't know the accurate rate yet to solve for, we can't decide ahead to pick the forward or backward npmt() based on the rate and n. But a good guess (which we have) will help! It might also be interesting to see how this affects N, PV, PMT and FV computations, wben we aren't using the rate solver. We can pick the forward or backward npmt() to get parameters j, k, l, r, s and use the corresponding N, PV, PMT, and FV formulas to compute those as follows: For the forward npmt(): n = log((k*pmt-fv*j)/(k*pmt+pv*j))/l); pv = k*pmt*r/j-fv*s; pmt.= (fv*s+pv)*j/k/r; fv = (k*pmt*r/j-pv)/s; For the backward npmt(): n = log((k*pmt-fv*j)/(k*pmt+pv*j))/l); // same as forward pv = -(k*pmt*r/j+fv)/s pmt.= -(pv*s+fv)*j/k/r; fv = -k*pmt*r/j+pv*s; - Rob "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)