Post Reply 
TVM solve for interest rate, revisited
06-15-2024, 03:29 PM
Post: #44
RE: TVM solve for interest rate, revisited
I recently translated find_rate() for HP71B (with test samples)
But, instead of copy/paste the code, I redo the math.
HP71B code seems simpler, with just as good accuracy.

I am updating old with new, in iter_i(), post #31
Code:
OLD                                             NEW

local x = i/EFF(i,n)                            local s = EFF(i,n)
local k, y = (pv+fv)*x, n*x-1                   local k = (pv+fv)/s
local num, den = y+(n-1)*i, i+i*i               local d = k*(1-n*(s+1)/(s+s/i)) + pv
f = k + pv*i + pmt                              f = (k + pv)*i + pmt
eps = f / (k*num/den - pv)                      eps = -f / d

Just to check math again, for df/di

s = (1+i)^n - 1
k = (pv+fv)/s       // note: (k*s) = (pv+fv) = constant

ln(i/s)' = ln(i)' - ln(s)'
(i/s)' / (i/s) = 1/i - n*(s+1)/(1+i)/s
s * (i/s)' = 1 - n*(s+1)/(s+s/i)

f = (k + pv)*i + pmt = (k*s)*(i/s) + pv*i + pmt
f' = (k*s)*(i/s)' + pv = k*(1-n*(s+1)/(s+s/i)) + pv
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: TVM solve for interest rate, revisited - Albert Chan - 06-15-2024 03:29 PM



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