The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(71B) calculate interest rate
12-20-2019, 04:14 PM
Post: #1
(71B) calculate interest rate
Calculate interest rate, given N, FV, PV, PMT
For term (1+i)n - 1, it use the more accurate expm1(n * log1p(i)) = FNE(n*FNL(i))

Code:
10 INPUT "n, fv, pv, pmt ? ";N,F,P,M
20 DEF FNE(X) @ Y=EXP(X) @ FNE=Y-1-Y*(LN(Y)-X) @ END DEF
30 DEF FNL(X) @ Y=1+X @ FNL=LN(Y)-(Y-1-X)/Y @ END DEF
40 DEF FNF(I) @ Y=F+P+(M/I+P)*FNE(N*FNL(I)) @ DISP I,Y @ FNF=Y @ END DEF
50 I1=-(M*N+P+F)/(N*((N-1)/2*M+P))
60 I2=.9*I1
70 DISP FNROOT(I1,I2,FNF(FVAR))

Example, from https://www.hpmuseum.org/forum/thread-6725.html

>RUN
n, fv, pv, pmt ? 168, 10925.76, 0, -45
4.79863130882E-3     -655.6829061
5.33181256535E-3     -1255.8749515
4.21615468581E-3     -41.4514876
4.17684617474E-3     -1.4838737
4.17538677149E-3     -.0035171
4.17538330417E-3     -.0000003
4.17538330387E-3     0
4.17538330387E-3

Note both guesses (I1,I2) over-estimated interest rate on purpose.
If they bracketed the true rate, secant's method tends to over-shoot all over.

>60 I2=.5*I1
>RUN
n, fv, pv, pmt ? 168, 10925.76, 0, -45
2.66590628268E-3     1404.76181571
5.33181256535E-3     -1255.8749515
3.99885942402E-3     177.2179603
4.16369398215E-3     11.8480798
4.17461116346E-3     .7831243
4.7532118644E-3       -606.2697042
4.1753575833E-3       .0260875
4.46428472385E-3     -298.0104305
4.17538287345E-3     .0004364
4.31983379865E-3     -147.7508024
4.1753833001E-3       .0000038
4.24760854938E-3     -73.5647316
4.17538330383E-3     0
4.17538330383E-3
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(71B) calculate interest rate - Albert Chan - 12-20-2019 04:14 PM



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