Post Reply 
(11C) TVM for HP-11C
12-03-2020, 08:53 PM (This post was last modified: 12-04-2020 01:41 PM by Albert Chan.)
Post: #9
RE: (11C) TVM for HP-11C
(12-03-2020 05:53 PM)bshoring Wrote:  If I understand correctly, this program uses a modified Newton method to solve.

Yes !

Let a = (PV+FV)/(-PMT), using cash-flow sign-convention (results of post#3, LBL A)
We can interpret it as number of payments, if interest rate is zero.

Case FV=0: a*i/(1-k) = 1       → f(i) = a*i - (1-k) = 0       → f'(i) = a - k*n/(1+i)
Code:
function pv_i(n, a, i)
    i = i or 1/a - a/n^2
    return function()
        local k = (1+i)^-n
        i = i - (a*i-(1-k)) / ((1-k)/i - k*n/(1+i))
        return i
    end
end

Case PV=0: a*i/(K-1) = 1       → f(i) = a*i - (K-1) = 0       → f'(i) = a - K*n/(1+i)
Code:
function fv_i(n, a, i)
    i = i or 2*(a-n)/(a + (n-1)^2)
    return function()
        local K = (1+i)^n
        i = i - (a*i-(K-1)) / ((K-1)/i - K*n/(1+i))
        return i
    end
end

Iterations were setup with Newton's method.
But, denominator is not quite f'(i), resulting in better correction.

lua> g = pv_i(12, 5000/500) -- guess_i = 0.030555555555555558
lua> g(), g(), g()
0.02922075497755343        0.02922854050171087       0.029228540769134212

lua> g = fv_i(12, 5000/400) -- guess_i = 0.00749063670411985
lua> g(), g(), g()
0.007390656157378769      0.007390622804155507      0.007390622804147247
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: 7 Guest(s)