Post Reply 
(71B) calculate interest rate
12-22-2019, 03:07 PM (This post was last modified: 12-27-2019 12:23 PM by Albert Chan.)
Post: #5
RE: (71B) calculate interest rate
(12-21-2019 03:44 PM)J-F Garnier Wrote:  
(12-20-2019 10:10 PM)Albert Chan Wrote:  Playing emulator interactively, this is unexpected ...
>FNROOT(I1, .5*I1, FNF(FVAR))
MATH ERR:Kybd FN in FNROOT/INTEGRAL

Doesn't come from the emulator, actually.

As the error message implies, it is not allowed to use a User-Defined function in FNROOT/INTEGRAL from the keyboard.

Thanks J-F Garnier.
A trick to get around this limitation is to wrap FNROOT inside an user function.

>PURGE
>10 INPUT "N, FV, PV, PMT ? ";N,F,P,M
>20 DEF FNF(I) @ Y=F+P+(M/I+P)*EXPM1(N*LOGP1(I)) @ DISP I,Y @ FNF=Y @ END DEF
>30 I1=-(M*N+P+F)/(N*((N-1)/2*M+P))
>40 I2=.9*I1
>50 DEF FNS(A,B)=FNROOT(A,B,FNF(FVAR))
>
>RUN
N, FV, PV, PMT ? 168, 10925.76, 0, -45
>I=FNS(I1,.5*I1)
2.66590628268E-3     1404.76181566
5.33181256535E-3     -1255.8749515
3.99885942402E-3     177.2179603
4.16369398215E-3     11.8480797
4.17461116337E-3     .7831244
4.75321186436E-3     -606.2697042
4.1753575833E-3       .0260875
4.46428472383E-3     -298.0104306
4.17538287345E-3     .0004365
4.31983379864E-3     -147.7508024
4.1753833002E-3       .0000036
4.24760854942E-3     -73.5647316
4.17538330374E-3     .0000001
4.21149592658E-3     -36.7050556
4.17538330384E-3     0

Update: this may improve rate guesses closer to true rate.

y = (1+I)^N-1 ≈ NI / (1 - ½ (N-1)I), Pade[1,1] approximation

Using this rough estimate of y for equation F + P + y(P + M/I) = 0
Solve for I, we have I = (F+P+M*N) / ((N-1)/2*(F-P) - P)

Above should be better than I1 estimate, which assumed no compounding.
Note: I1 is solution of F + P(1+NI) + m Σ(1+kI, k=0 to N-1) = 0

To make I2 still over-estimated true rate, take the arithmetic mean.
For the same reasoning, I1 can be reduced the same way.

>I1=(F+P+M*N) / (N*((1-N)/2*M - P))  → 5.33181256535E-3
>I2=(F+P+M*N) / ((N-1)/2*(F-P) - P)    → 3.68930884387E-3
>I3=(I1+I2)/2                                          → 4.51056070461E-3
>I4=(I1+I3)/2                                          → 4.92118663498E-3
>I=FNS(I3,I4)
4.51056070461E-3     -346.6853844
4.92118663498E-3     -790.3342398
4.18968078622E-3     -14.5135902
4.17566057222E-3     -.2812298
4.17538353441E-3     -.0002338
4.1753833039E-3       0
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-22-2019 03:07 PM



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