(11C) TVM for HP-11C
|
12-07-2020, 06:55 PM
(This post was last modified: 06-16-2021 01:44 PM by Albert Chan.)
Post: #15
|
|||
|
|||
RE: (11C) TVM for HP-11C
For getting interest rate for the general case, npmt() is very nice formula.
TVM equation, for "net payment", NPMT = NFV * i/(K-1): Code: require 'mathx' lua> n, pv, pmt, fv = 36, 30000, -550, -15000 lua> i1 = guess_i(n, pv, pmt, fv) lua> p1 = npmt(n, i1, pv, pmt, fv) lua> i1, p1 0.005804795434882038 -0.006442911074373114 lua> i2 = 1.001*i1 -- p1<0, i1 is a bit low lua> p2 = npmt(n, i2, pv, pmt, fv) lua> i2, p2 0.005810600230316919 0.12838859778003098 lua> i1 - p1/(p2-p1) * (i2-i1) -- secant's method 0.005805072816490459 For comparison, with same i1, i2, and secant's method, for other TVM formula: 0.005805072843740277 -- NPV formula 0.005805072788863714 -- NFV formula Solve npmt()=0, using Newton's method, we have: (guess_i code here) Code: function loan_rate(n, pv, pmt, fv, i) lua> g = loan_rate(n, pv, pmt, fv) lua> g(), g() 0.005805072819567153 0.005805072819420132 lua> g = loan_rate(-n, fv, -pmt, pv) -- time symmetric, as expected lua> g(), g() 0.005805072819567159 0.005805072819420132 Update: numbers adjusted with updated guess_i() |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 6 Guest(s)