PC-1211, PC-1250, etc. TVM
|
06-02-2024, 06:37 PM
Post: #12
|
|||
|
|||
RE: PC-1211, PC-1250, etc. TVM
(05-29-2024 09:17 PM)robve Wrote: B=1 (begin mode) We can make this to END mode, by shift up payment: {PV,FV} ← {PV+PMT, FV-PMT} N=40, PV=860, PMT=-40, FV=-960 We can split up into 2 loans (combined, we get back original loan) #1: N=40, PV=860-x, PMT=-40, FV=-(860-x) #2: N=40, PV=x, PMT=0, FV=(860-x)+(-960) = -(x+100) Unlike original loan, splitted loans have have direct formula for rate. From 1st loan, rate = pmt/(x-pv) = 40/(860-x) From 2nd loan, x*(1+rate)^N = x - (PV+FV) --> x*((1+rate)^N-1) + (PV+FV) = 0 --> f = x + (PV+FV) / ((1+rate)^N-1) = 0 // flatten curve to make Newton's method efficient If x=0, 1st loan rate = 40/860 = 4.65%, 2nd loan rate = ∞ --> (x>0, rate > 4.65%) f(x=10) = 10 + (-100) / ((1+40/850)^40-1) = -8.89363 f(x=20) = 20 + (-100) / ((1+40/840)^40-1) = 1.58000 Interpolate for f=0, we get x = 18.4914 --> rate = 4.75337% (all digits correct) Below code assumed pmt ≠ 0 (we have direct rate formula for pmt=0) We use smaller size edge rates [pmt/-pv, pmt/fv] as guess, same as Plus42. For this example, rate guess = -40 / (-1000+40) ≈ 4.16667% 10 B=1 @ N=40 @ P=900 @ M=-40 @ F=-1000 15 IF B THEN P=P+M @ F=F-M ! Now, B=0 20 DEF FNF(X) @ D=X-P @ I=M/D @ S=(1+I)^N 25 D=1 - (P+F)/(S-1)^2 * N*S/(1+I) * -I/D 30 FNF=X+(P+F)/(S-1) @ END DEF 40 X=(ABS(P)<ABS(F))*(P+F) @ Y=FNF(X) 50 H=-Y/D @ X=X+H @ Y=FNF(X) 60 DISP 100*I,X,Y @ IF X+H*H<>X THEN 50 >run 4.75245128279 18.32908914 -.1698427457 4.75336718645 18.4912666946 -.000000398 4.75336718859 18.4912670746 .0000000071 Interestingly, converge rate seems to match NPMT formula with Newton's method. |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 8 Guest(s)