Post Reply 
(71B) calculate interest rate
02-13-2020, 03:41 PM
Post: #9
RE: (71B) calculate interest rate
Again, basing the code on my 3-points fit rate finder (post #6), but with different guess.

\( \large {1\over I} ≈
{\binom{N}{3}M + \binom{N}{2}P \over \binom{N}{2}M + \binom{N}{1}P} -
{\binom{N}{2}M + \binom{N}{1}P \over F + P + M N}\)

10 INPUT "N, FV, PV, PMT ? ";N,F,P,M
20 DEF FNS(X1,Y1,X2,Y2)=X1-Y1*(X2-X1)/(Y2-Y1)
30 DEF FNF(I)
40 A=N @ IF I THEN A=EXPM1(N*LOGP1(I))/I
50 FNF=F+P+A*(P*I+M)
60 END DEF
70 C2=N*(N-1)/2 @ C3=C2*(N-2)/3
80 C3=C3*M+C2*P @ C2=C2*M+N*P @ C1=F+P+M*N @ C3=C3/C2
100 X1=1/(C3-C2/C1)
110 Y1=FNF(X1) @ DISP X1,Y1 @ IF Y1=0 THEN END
120 X2=1/(C3-C2/(C1+Y1))
130 Y2=FNF(X2) @ DISP X2,Y2 @ IF Y2=0 THEN END
140 X3=FNS(X1,Y1,X2,Y2)
150 Y3=FNF(X3) @ DISP X3,Y3 @ IF Y3=0 THEN END
160 E3=-Y3*FNS((X3-X2)/(Y3-Y2),Y2,(X3-X1)/(Y3-Y1),Y1)
170 X1=X2 @ Y1=Y2 @ X2=X3 @ Y2=Y3 @ X3=X3+E3
180 IF .00001*E3+X3-X3 THEN 150
190 DISP X3

>RUN
N, FV, PV, PMT ? 168, 10925.76, 0, -45
4.1171440611E-3       58.8707146
4.17253086536E-3     2.8926652
4.17539297797E-3     -.0098122
4.17538330384E-3     0
>RUN
N, FV, PV, PMT ? 600, 1e6, 0, -250
3.9653228628E-3      385578.34249
4.24281053755E-3     311571.332995
5.41104048363E-3     -130995.27126
5.15294183714E-3     -11161.26946
5.1267015499E-3      216.64945
5.12720400635E-3     .112712
5.12720426786E-3
>RUN
N, FV, PV, PMT ? 30,50000,1000,-1000
3.54153653967E-2     863.8049367
3.63975416852E-2     96.4591994
.03652100616            -.997799
3.65197435458E-2     -.0000155
3.65197435262E-2
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 - 02-13-2020 03:41 PM



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