(71B) calculate interest rate
12-29-2019, 02:46 PM
Post: #6
 Albert Chan Senior Member Posts: 1,914 Joined: Jul 2018
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
 « Next Oldest | Next Newest »

 Messages In This Thread (71B) calculate interest rate - Albert Chan - 12-20-2019, 04:14 PM RE: (71B) calculate interest rate - Joe Horn - 12-20-2019, 08:36 PM RE: (71B) calculate interest rate - Albert Chan - 12-20-2019, 10:10 PM RE: (71B) calculate interest rate - J-F Garnier - 12-21-2019, 03:44 PM RE: (71B) calculate interest rate - Albert Chan - 12-22-2019, 03:07 PM RE: (71B) calculate interest rate - Albert Chan - 12-29-2019 02:46 PM RE: (71B) calculate interest rate - Albert Chan - 01-02-2020, 05:43 PM RE: (71B) calculate interest rate - Albert Chan - 01-06-2020, 09:16 PM RE: (71B) calculate interest rate - Albert Chan - 02-13-2020, 03:41 PM

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