Post Reply 
(71B) calculate interest rate
12-29-2019, 02:46 PM
Post: #6
RE: (71B) calculate interest rate
This version use 3-points fit to interpolate for the root, instead of secant line.
Note: this assumed x = f(y), where f is a parabola, and interpolate for x as f(0)
Note: initial 2 rate guesses are arithmetic mean and harmonic mean of I1, I2.

10 INPUT "N, FV, PV, PMT ? ";N,F,P,M
20 DEF FNI(X1,Y1,X2,Y2)=X1-Y1*(X2-X1)/(Y2-Y1)
30 DEF FNF(I)=F+P+(P+M/I)*EXPM1(N*LOGP1(I))
40 I1=(F+P+M*N)/(N*((1-N)/2*M-P))
50 I2=(F+P+M*N)/((N-1)/2*(F-P)-P)
60 X1=(I1+I2)/2 @ Y1=FNF(X1) @ DISP X1,Y1
70 X2=I1*I2/X1 @ Y2=FNF(X2) @ DISP X2,Y2
80 X3=FNI(X1,Y1,X2,Y2)
90 Y3=FNF(X3) @ DISP X3,Y3
100 IF Y3=0 THEN END
110 E3=-Y3*FNI((X3-X2)/(Y3-Y2),Y2,(X3-X1)/(Y3-Y1),Y1)
120 X1=X2 @ Y1=Y2 @ X2=X3 @ Y2=Y3 @ X3=X3+E3
130 IF .00001*E3+X3-X3 THEN 90
140 DISP X3

>RUN
N, FV, PV, PMT ? 168, 10925.76, 0, -45
4.51056070461E-3     -346.6853844
4.36103281596E-3     -190.3488201
4.17897395274E-3     -3.6426516
4.17538425315E-3     -.0009629
4.1753833038E-3       0

>RUN
N, FV, PV, PMT ? 600, 1E6, 0, -250
1.08792431831E-2     -14144337.7743
4.93576250272E-3     78873.414844
4.96872148862E-3     65799.655312
5.13383450348E-3     -2862.19318
5.12721962668E-3     -6.6198
5.12720426664E-3     .00052
5.12720426785E-3
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: (71B) calculate interest rate - Albert Chan - 12-29-2019 02:46 PM



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