Post Reply 
(11C) TVM for HP-11C
05-10-2022, 09:35 PM (This post was last modified: 05-15-2022 02:46 PM by Albert Chan.)
Post: #17
RE: (11C) TVM for HP-11C
(12-05-2020 01:05 AM)Albert Chan Wrote:  From thread: Fun math algorithms:
(10-19-2020 11:05 PM)Albert Chan Wrote:  We can use \(C_±\) to solve Time value of money problem, if I is small, and N not too big.

XCas> C(d) := 1 + N*I*(N*I+d*6)/12 + I/2;       // compounding factor, d is direction
XCas> eqn := C(1)*PV + C(-1)*FV + N*PMT;       // variables follow cash flow sign convention

XCas> factor(symb2poly(eqn,I)); // quadratic coefficients, for I

[N^2*(FV+PV)/12 , (-FV*N+N*PV+FV+PV)/2 , N*PMT+FV+PV]

I noticed exact definition of C, if we take away N*I/2, it turned to even function (of N)

XCas> C := I*N/(1 - (1+I)^-N)
XCas> simplify(C - C(N=-N))      → N*I
XCas> series(C - N*I/2, I, 0, 3, polynom) // even powers of N, as expected

1 + I/2 + (-1+N^2)/12*I^2 + (1-N^2)/24*I^3

If we define Ce = C - I*N/2, we avoided thinking of "backward in time" with negative (N,PMT)
Quoted C(d) dropped the term I^2/12, we might as well put it back in.

XCas> Ce := 1 + I/2 + (N^2-1)/12*I^2 // truncated O(I^3) terms
XCas> NPMT := (Ce+N*I/2)*PV + (Ce-N*I/2)*FV + N*PMT
XCas> factor(e2r(NPMT,I)); // quadratic coefficients, for I

[(N^2-1)*(FV+PV)/12, (-FV*N+N*PV+FV+PV)/2 , N*PMT+FV+PV]

Only difference with previous version is N^2 replaced by (N^2-1)

Code:
function guess_i(n, pv, pmt, fv)    -- cash-flow sign convention
    local a = (fv+pv)/n
    local b = (fv-pv)-a
    local c = (a+pmt)/b
    b = (n*n-1)*a*c/b               -- I coef = [b/c/3, -2, 4c]
    return c * (b-3)/(b-1.5)        -- pade(4c/(1+sqrt(1-4b/3)),b,2,2)
end

Examples shown in this thread, estimated rate slightly improved.
With updated guess_i(n, pv, pmt, fv):

lua> guess_i(12, 5000, -500, 0) -- OP example
0.029209500177242102
lua> guess_i(12, 0, -400, 5000) -- OP example
0.007391057003072031
lua> guess_i(36, 30000, -550, -15000) -- car lease example
0.0058048457798059476
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(11C) TVM for HP-11C - Gamo - 05-09-2019, 01:15 AM
RE: (11C) TVM for HP-11C - Gamo - 12-03-2019, 10:12 AM
RE: (11C) TVM for HP-11C - Gamo - 02-13-2020, 06:14 AM
RE: (11C) TVM for HP-11C - bshoring - 12-02-2020, 09:02 PM
RE: (11C) TVM for HP-11C - Gamo - 12-03-2020, 08:23 AM
RE: (11C) TVM for HP-11C - Dave Britten - 12-03-2020, 01:48 PM
RE: (11C) TVM for HP-11C - bshoring - 12-03-2020, 05:53 PM
RE: (11C) TVM for HP-11C - Dave Britten - 12-03-2020, 06:08 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-03-2020, 08:53 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-04-2020, 08:01 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-05-2020, 01:05 AM
RE: (11C) TVM for HP-11C - Albert Chan - 12-05-2020, 03:46 AM
RE: (11C) TVM for HP-11C - Albert Chan - 05-10-2022 09:35 PM
RE: (11C) TVM for HP-11C - Albert Chan - 05-11-2022, 01:07 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-06-2020, 02:32 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-06-2020, 04:41 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-07-2020, 06:55 PM
RE: (11C) TVM for HP-11C - Albert Chan - 12-08-2020, 03:05 PM
RE: (11C) TVM for HP-11C - Albert Chan - 05-14-2022, 12:26 PM



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