Looking for TVM contributions
|
06-22-2024, 11:58 PM
Post: #81
|
|||
|
|||
RE: Looking for TVM contributions
(06-22-2024 08:00 PM)robve Wrote: - The 3rd case FVerror=100 looks really bad, but it means that we computed FV=-900 instead of FV=-1000 which was discussed in this thread before why this happens. This example jogged my memory. I finally get what you mean by FVerr! I had thought FVerr = NFV(n,i2,pv,pmt,fv), calculated at higher precisions. Then, FVerr can be used tell if i2 is good, or bad. Because we have direct formula for FV, it can save a lot of time. But it is really testing BASIC FV code, run in 10 decimals, can round-trip back. Even if i2 was really bad, as long as FV can round-trip, it is considered good. Conversely, if solved i2 was dead on, npmt=0, huge FVerr can make it bad. Quote:It is very hard (impossible?) to improve this result with only 10 digits BCD precision as the least significant digit in i% causes FV to sway. Perhaps we can! On this thread, post#61, I mentioned with i*n>0, r=(1+i)^n-1 is better. Since i*n>0 is more common, this r should benefit every part of your code (*) S=(1+J)^-N and R=S-1 --> 1 = S-R Let r, s = R,S, but with N negated --> R/S = 1-1/S = 1-s = -r We just replace (R,S) with (r,s): F = (K*M*R/J-P)/S = K*M/J*(R/S) + P*(1-1/S) - P = -(K*M/J+P)*r - P P = K*M*R/J-F*S = S*(K*M/J*(R/S)-F) = -(K*M/J*r+F)/s M = (P+F*S)*J/K/R = ((P+F)*S-R*P)*(J/K)/R = -((P+F)/r+P)*(J/K) Edge case J=0: P+F+N*M*K = 0 --> M = -(P+F)/(N*K) npmt' = (P+F)/r*(1-N*s/(r+r/J)) + P npmt = ((P+F)/r + P)*J + M*K Newton: J = J - npmt/npmt' (*) there are other factors to consider besides r, so mileage may vary. Post #45 of this thread, HP71B reduce size of P, using time-symmetry. It also adjusted B to 0 --> K=1+B*J = 1, making code more accurate. |
|||
06-23-2024, 06:03 PM
(This post was last modified: 06-23-2024 06:27 PM by robve.)
Post: #82
|
|||
|
|||
RE: Looking for TVM contributions
(06-22-2024 11:58 PM)Albert Chan Wrote:(06-22-2024 08:00 PM)robve Wrote: - The 3rd case FVerror=100 looks really bad, but it means that we computed FV=-900 instead of FV=-1000 which was discussed in this thread before why this happens. We're firing off too many posts with progress and observations Can barely keep up myself at times... (06-22-2024 11:58 PM)Albert Chan Wrote:Quote:It is very hard (impossible?) to improve this result with only 10 digits BCD precision as the least significant digit in i% causes FV to sway. I had posted some initial observations with respect to S and R in this thread, but that went nowhere, because the impact is not consistent. It's more complicated. I have experimented a bit more with this idea and found that if pv + fv < -n*pmt then applying "time reversal" is beneficial, meaning that we internally use r = expm1(n*log1p(j)) with rate j instead of r = expm1(-n*log1p(j)) and swapping pv with fv with negating. Note that when pv + fv = -n*pmt the rate is zero. I collected results for this selective "time reversal" applied. It is almost perfect to improve the accuracy of the results for the set of test cases by reducing both the final npmt and the FV error. However, FV error may be lower simply because of the change in R and S using the "time reversed" FV formula (see here), so there is that. So in the results I've also included npmt (at the root rate) in addition to the FV error. The results are shown in the attached PDF. I marked rows with color background to show when time reversal was applied and when it improved the results (green: 6 cases), made it worse (red: 1 case) or did nothing/little (blue: 2 cases): tvmperfcomp-reversal-newton-hybrid.pdf (Size: 46.52 KB / Downloads: 5) Both Newton and Hybrid benefit from selective time reversal. Newton does need a second phase (g=1) to produce more accurate results versus Hybrid with one phase (g=0). Hybrid has fewer evals (98 versus 105) and slightly fewer error cases (4 versus 5) but that could be just noise! - Rob PS. also compared these results to the results when always reversing, but always reversing also introduces new errors elsewhere and we end up with more error cases overall. But it does show there is still room for improving selective reversal. "I count on old friends to remain rational" |
|||
07-05-2024, 09:39 PM
Post: #83
|
|||
|
|||
RE: Looking for TVM contributions | |||
07-05-2024, 09:44 PM
Post: #84
|
|||
|
|||
RE: Looking for TVM contributions | |||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 13 Guest(s)