TVM solve for interest rate, revisited
|
05-13-2022, 11:41 PM
(This post was last modified: 07-17-2022 08:48 PM by Albert Chan.)
Post: #3
|
|||
|
|||
RE: TVM solve for interest rate, revisited
(05-13-2022 09:31 PM)Albert Chan Wrote: Let t = tanh(n/2*log1p(x)), put Ce back to NPMT: We can also solve f=0, for t: tanh(n/2*log1p(x)) = -A*x/(pmt+B*x) There is a trivial solution, when x=0. We divide both side by x, to remove it. XCAS> t1 := tanh(n/2*log1p(x))/x XCAS> t2 := -A/(pmt+B*x) We approximate t1 by pade approximation. To keep things simple, we wanted degree(numerator)=1, degree(denominator)=2. This allow solving for guess rate x, with simple quadratic. XCAS> p1 := pade(t1,x,3,2) (6*n+3*n*x) / (12+12*x+2*x^2+n^2*x^2) Cross multiply, to get quadratic coefs. XCAS> P := e2r(numer(p1)*denom(t2) - denom(p1)*numer(t2)) [2*A+3*B*n+A*n^2, 12*A+6*B*n+3*n*pmt, 12*A+6*n*pmt] Let's try previous post example XCAS> P2 := P(A=(pv+fv)/2, B=(pv-fv)/2) XCAS> proot(P2(n=10,pv=50,pmt=-30,fv=100)) [-0.268464164628, 0.485855468976] This is not much better than using edges for rate guesses. The example is hard. Most cases, rate approximation is good. Car lease examples, from Fun math algorithms proot(P2(n=36,pv=30000,pmt=-550,fv=-15000)) .* 12 [-4.89392664913, 0.0696603112801] // True APR = 6.96608738330 % Just as previously done with guess_i(), we avoid using square roots. (also, we only keep the "small" root) Code: function guess_i2(n, pv, pmt, fv) lua> guess_i2(10,50,-30,100) -- the "hard" example -0.3460122699386503 lua> guess_i2(36,30000,-550,-15000) * 12 -- car lease example 0.06966051503474308 |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)