Looking for TVM contributions
|
05-25-2024, 01:09 AM
Post: #28
|
|||
|
|||
RE: Looking for TVM contributions
(05-24-2024 10:05 PM)dm319 Wrote: do_n(I%YR = 25%, PV = -100000, PMT = 2083.333334, FV = 0, p = 0) lua> i,pv,pmt,fv = .25/12, -1e5, 2083.333334, 0 lua> -(pv + fv) / (fv*i - pmt) * i -0.99999999968 lua> -log1p(_) / log1p(i) -- do_n() 1060.303385972225 We avoided cancellation error, (fv*i - pmt) = -pmt, but it had to calculate -log1p(-1 + ε) lua> pv*i, pmt -2083.333333333333 2083.333334 lua> pv*i + pmt 6.666668923571706e-07 lua> -(pv + fv) / _ * i 3124998942.076121 lua> log1p(_) / log1p(i) -- do_n(), time-symmetric version 1060.3033735821105 If we apply time symmetry, -log1p(-1+ε) issue goes away. However, (pv*i + pmt) denominator had massive cancellation! Let's scale money by 3e6, to avoid massive cancellation error (we work with integers, to avoid lua dec↔bin conversion error) lua> pv,pmt = pv * 3e6, pmt * 3e6 lua> pv*i + pmt 2 lua> -(pv + fv) / _ * i 3.125e+09 lua> log1p(_) / log1p(i) -- do_n() 1060.30339000051 Plus42: 3.125E9 LN1+X .25 Enter 12 ÷ LN1+X ÷ 1,060.303390000510007127328529884891 Quote:I couldn't understand why the plus42 code didn't have p in the equation. No, not time-symmetry. p=1 get transformed to p=0, thus not in tvm formula. (see tvm_begin()) For this problem, we have exactly the same issue. Again, scale money by 3e6, to avoid cancellation errors. lua> pmt = 2040.816327 * 3e6 lua> pv, fv = pv+pmt, fv-pmt -- do_n(), p=0 lua> pv, pmt, fv -293749999998 6250000002 -6250000002 lua> pv*i + pmt -- = 23 / 16 1.4375 lua> -(pv + fv) / _ * i -- = 1e11 / 23 4347826086.956522 lua> log1p(_) / log1p(i) -- do_n() 1076.3195443677068 Plus42 : 1E11 Enter 23 ÷ LN1+X .25 Enter 12 ÷ LN1+X ÷ 1,076.319544367706646435106131044347 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)