Post Reply 
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:
PV*S + PMT*K*R/I + FV = 0
with K=1+B*I and R=EXPM1(-N*LNP1(I)) and S=R+1

Compare this to

FV = (K*PMT*R/I-PV)/S
K*PMT*R/I - PV - FV*S = 0

This gives the same TVM problem.

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"
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Looking for TVM contributions - dm319 - 05-12-2024, 06:58 PM
RE: Looking for TVM contributions - dm319 - 05-12-2024, 08:48 PM
RE: Looking for TVM contributions - dm319 - 05-12-2024, 08:49 PM
RE: Looking for TVM contributions - dm319 - 05-12-2024, 08:00 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 11:04 AM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 05:58 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 05:59 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 08:34 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 08:31 PM
RE: Looking for TVM contributions - dm319 - 05-15-2024, 01:00 PM
RE: Looking for TVM contributions - dm319 - 05-15-2024, 12:57 PM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 10:05 PM
RE: Looking for TVM contributions - dm319 - 05-25-2024, 01:43 PM
RE: Looking for TVM contributions - dm319 - 05-25-2024, 08:40 PM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 11:22 AM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 02:58 PM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 09:22 PM
RE: Looking for TVM contributions - dm319 - 06-02-2024, 02:46 PM
RE: Looking for TVM contributions - robve - 06-09-2024, 02:04 AM
RE: Looking for TVM contributions - dm319 - 06-09-2024, 12:15 PM
RE: Looking for TVM contributions - robve - 06-09-2024, 03:29 PM
RE: Looking for TVM contributions - dm319 - 06-09-2024, 06:05 PM
RE: Looking for TVM contributions - dm319 - 06-09-2024, 10:00 PM
RE: Looking for TVM contributions - robve - 06-12-2024, 08:48 PM
RE: Looking for TVM contributions - robve - 06-14-2024, 03:23 PM
RE: Looking for TVM contributions - robve - 06-14-2024, 10:11 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 03:54 AM
RE: Looking for TVM contributions - dm319 - 06-12-2024, 11:56 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 03:05 AM
RE: Looking for TVM contributions - robve - 06-15-2024, 05:48 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 09:52 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 01:38 PM
RE: Looking for TVM contributions - robve - 06-16-2024, 05:18 PM
RE: Looking for TVM contributions - Werner - 06-17-2024, 05:11 PM
RE: Looking for TVM contributions - robve - 06-16-2024, 08:26 PM
RE: Looking for TVM contributions - dm319 - 06-16-2024, 11:55 PM
RE: Looking for TVM contributions - robve - 06-17-2024, 09:03 PM
RE: Looking for TVM contributions - robve - 06-18-2024 03:27 AM
RE: Looking for TVM contributions - robve - 06-19-2024, 12:57 AM
RE: Looking for TVM contributions - robve - 06-19-2024, 02:01 AM
RE: Looking for TVM contributions - robve - 06-19-2024, 03:47 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 04:03 AM
RE: Looking for TVM contributions - robve - 06-20-2024, 05:07 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 04:30 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 06:27 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 02:33 AM
RE: Looking for TVM contributions - robve - 06-21-2024, 09:04 PM
RE: Looking for TVM contributions - robve - 06-22-2024, 08:00 PM
RE: Looking for TVM contributions - robve - 06-23-2024, 06:03 PM
RE: Looking for TVM contributions - dm319 - 07-05-2024, 09:39 PM
RE: Looking for TVM contributions - dm319 - 07-05-2024, 09:44 PM



User(s) browsing this thread: 13 Guest(s)