Post Reply 
(71B) calculate interest rate
01-02-2020, 05:43 PM (This post was last modified: 01-05-2020 09:42 PM by Albert Chan.)
Post: #7
RE: (71B) calculate interest rate
This version extrapolate for rate, using Steffensen's method
I used HP71B quirky RES behavior on line-50, see HP71B RES bug?

Code:
10 INPUT "N, FV, PV, PMT ? ";N,F,P,M
20 DEF FNA(A,B,C)=C-(C-B)^2/(C-B-(B-A))
30 DEF FNI(I)=EXPM1(LOGP1(-I*(F+P)/(M+I*P))/N)
40 DISP 4*(F+P+M*N)/((N-1)*(F-M*N)-(3*N+1)*P)
50 DISP FNA(RES,FNI(RES),FNI(RES))
60 GOTO 50

To keep code short, it run until extrapolation hit by divide-by-0 (or other) error.

>DEFAULT OFF     ! error if overflow/underflow, divide-by-0 ...
>RUN
N, FV, PV, PMT ? 168, 10925.76, 0, -45
4.36103281596E-3
4.17891608926E-3
4.17538469191E-3
4.17538330384E-3
ERR L20:0/0

>RUN
N, FV, PV, PMT ? 600, 1e6, 0, -250
4.93576250272E-3
5.12771388025E-3
5.12720427126E-3
5.12720426785E-3
ERR L20:0/0

Note: above code require very good guess for rate. Sad
Going for FV errors (see previous posts) is much better.

Example: tried this with default guess failed.
>RUN
N, FV, PV, PMT ? 40, 0, 25000, -1000
4.09556313993E-2
ERR L30:LOG(neg)

We need better guess (for this case, 2.1% ≤ guess ≤ 3.1%)
>.025 @ RUN 50
.025
.025252440621
.025243859111
2.52438486204E-2
ERR L20:0/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 - 01-02-2020 05:43 PM



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