Post Reply 
TVM solve for interest rate, revisited
06-13-2024, 01:05 PM (This post was last modified: 06-15-2024 12:02 AM by Albert Chan.)
Post: #39
RE: TVM solve for interest rate, revisited
I recently discovered split loan method. Is this new? Smile

If loan split correctly, we can get a good guess rate, and formula to iterate for true rate.
(06-08-2024 11:47 PM)Albert Chan Wrote:  Solve with split loan method
f(x) = x + (pv+fv) / ((1+i)^n-1), where i = pmt / (x-pv)
Code:
Loan:  n  pv    pmt  fv
#1:    n  pv-x  pmt  x-pv      --> i = pmt / (x-pv)
#2:    n  x     0    (pv+fv)-x --> x = -(pv+fv) / ((1+i)^n-1)

Here is one with huge true rate (see post #22, #27, #28, #29)

lua> n, pv, pmt, fv = 10, -100, 10, 1e10
lua> tvm(n,nil,pv,pmt,fv, true)
Code:
1e-09                   999999995.5
0.22222222032098768     345130893.0191475
0.4241393063954123      127299482.5393054
0.6292750775369145      48106454.844047576
0.8468793905100045      18381292.76136444
1.0824224688331676      7062941.954833955
1.3400583139839632      2722233.2107647057
1.6234867740344179      1051054.2519718618
1.936322276082247       406212.4885288175
2.282247095736833       157054.32380092412
2.6649766778452406      60694.70062511578
3.0878290650500033      23400.014453658747
3.5521226148603975      8951.90999749287
4.052051396405174       3345.878170726684
4.560402776655654       1168.0978535777294
5.001365887839277       335.11729441390037
5.257160227141495       55.734261383772946
5.3187739972480506      2.306061198884663
5.321549001716665       0.004352499460765102
5.321554259137976       1.557395989948418e-08
5.3215542591567875      5.684341886080801e-13
5.321554259156788       -1.2505552149377763e-12
5.3215542591567875

tvm() picked time-reversed setup (x=0), edge = pmt/fv = 1e-9
The other edge (also x=0) is just as bad, edge = pmt/-pv = 0.1
Convergence is slow, because huge rate caused f(i) to be curvy.

(07-16-2022 02:58 PM)Albert Chan Wrote:  newx = function(x) return expm1(log1p(-(pv+fv)/(pmt/x+pv))/n) end

Above is from post#29, I just realize this can be easily explained as a split loan!
If we replace log1p(z) = ln(1+z), ln argument is:

-(pv+fv) / (pmt/x+pv) + 1 = -(fv-pmt/x) / (pv+pmt/x)

We might as well simplify this, with y = pmt/x
Code:
Loan:  n  pv        pmt     fv
#1     n  pv+y      0       fv-y        --> (1+i)^n = -(fv-y)/(pv+y)
#2     n  -y        pmt     y           --> i = pmt/y

We don't have to use the setup to solve rate. Guess i when y=0 is already good.

lua> y = 0
lua> i = EFF(-(pv+fv)/(y+pv), 1/n) -- guess
lua> tvm(n,i,pv,pmt,fv, true)
5.30957344513139        9.999999722758162
5.321456835153608      0.08065988603186725
5.321554252697288      5.347635692487529e-06
5.321554259156789      -1.3642420526593924e-12
5.321554259156788

Here is another way to split loan. (any more ways?)
Code:
Loan:  n  pv        pmt     fv
#1     n  pv+z      0       fv        --> (1+i)^n = -fv/(pv+z)
#2     n  -z        pmt     0         --> z = pmt * (1-(1+i)^-n)/i

Sign checks:
#1: sgn(pv+z) = sgn(-fv)
#2: sgn(z) = sgn(n*pmt), because NPMT is time-symmetrical, f=NPMT/n is not

lua> for loop=1,7 do i=APR(-fv/(pv+z)-1,n); z=pmt*-EFF(i,-n)/i; print(i,z) end
5.309573444801933      1.8833904463248339
5.321581577921809      1.8791405816968803
5.321554197006327      1.879150250410811
5.321554259298183      1.8791502284142771
5.321554259156466      1.8791502284643202
5.321554259156789      1.879150228464206
5.3215542591567875     1.8791502284642068



I don't know how to name this ... any idea?

EFF(i,n) = (1+i)^n - 1
APR(i,n) = (1+i)^(1/n) - 1

But google search effective rate formula, it was normally defined with mul/div.
To me this is less useful, so I added a third argument, in case true EFF, APR needed.

EFF(i,n,true) = EFF(i/n,n)
APR(i,n,true) = APR(i,n)*n

lua> EFF(0.12, 12, true)
0.12682503013196972
lua> APR(_, 12, true)
0.12
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-13-2024 01:05 PM



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