PC-1211, PC-1250, etc. TVM
|
06-03-2024, 06:44 PM
(This post was last modified: 06-04-2024 12:15 AM by robve.)
Post: #16
|
|||
|
|||
RE: PC-1211, PC-1250, etc. TVM
(06-03-2024 11:38 AM)Albert Chan Wrote:(06-02-2024 09:46 PM)robve Wrote: 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. First, I neglected to add zero tests in the updated version for f and f0 that get us to the root immediately. Second, finite precision especially BCD isn't behaving as smoothly. If we're not exactly at the root yet, it may not hurt to do a step when we keep the previous best guess to compare to later. Something like this: 34 IF SGN Y=SGN W IF ABS Y<ABS W GOTO 33 ' convergence? 35 IF Y<>0 IF W<>0 IF G LET G=0 GOTO 33 ' try one more time 36 IF ABS Y>ABS W LET I=V ' pick better one 37 RETURN This is one way I get better rates up to the last digit (10 digit BCD) that is off less than without this approach. But it may not always work. It appears to produce results that are often "retractable", meaning computing PMT with the computed rate gives the PMT value that we started with up to one ulp. - Rob "I count on old friends to remain rational" |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 17 Guest(s)