PC-1211, PC-1250, etc. TVM
|
06-02-2024, 09:46 PM
(This post was last modified: 06-04-2024 02:11 AM by robve.)
Post: #13
|
|||
|
|||
RE: PC-1211, PC-1250, etc. TVM
(06-01-2024 10:13 PM)Albert Chan Wrote: Plus42 uses NPMT formula and Newton's method for rate too. Indeed, that is an interesting approach. We could improve this a bit by iterating one more time after detecting a sign change or when f does not get better. We could also compare f to f0 to use the best rate corresponding to f or f0 whichever is closer to zero. In the Sharp code this would be: Code: 10 "B" B=B=0 : PRINT "BGN=";MID$("NY",B+1,1) : END where Y and W are f and f0, respectively. With this, a more accurate rate is obtain such as for PMT=-40 for the example. For PMT=-400 the rate is 80% and we get very close with 80.00000002%. I've also changed the code to substitute U=(1-S)/J inline, because when entering the rate I%=80 to compute FV we get a very bad FV=0 instead of FV=-1000 because of catastrophic cancellation in U=(1-S)/J. With the change we get FV=-893.8463964 instead of -1000. As we all know, this catastrophic cancellation can be avoided if we use LN1(x) and EXP1(x), which aren't built-in on SHARPs so we should roll out our own series computations, i.e. the alternative part that Dave has in his code computes LN1 but EXP1 is also required. This is a nice example why this matters (a lot). - Rob EDIT: correct typo "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 7 Guest(s)