(71B) calculate interest rate
12-20-2019, 04:14 PM
Post: #1
 Albert Chan Senior Member Posts: 1,848 Joined: Jul 2018
(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))

>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
 « 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)
{"found_math": false, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 0, "mathjax_display_tex": 0, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0, "katex": 0, "math-container": 0, "wp-katex-eq": 0, "align": 0, "equation": 0, "x-ck12": 0, "texerror": 0, "url": "https://www.hpmuseum.org/forum/showthread.php?mode=threaded&tid=14195&pid=125319", "fetch_time": 1657126033000000000, "content_mime_type": "text/html", "warc_filename": "crawl-data/CC-MAIN-2022-27/segments/1656104675818.94/warc/CC-MAIN-20220706151618-20220706181618-00270.warc.gz", "warc_record_offset": 855494553, "warc_record_length": 5862, "token_count": 1062, "char_count": 2316, "score": 3.671875, "int_score": 4, "crawl": "CC-MAIN-2022-27", "snapshot_type": "latest", "language": "en", "language_score": 0.5019822716712952, "file_path": "/sailhome/yjruan/project/latent-lm/data/processed/finemath-4plus/finemath-4plus/train-00008-of-00064.parquet"}