Post Reply 
Looking for TVM contributions
06-15-2024, 05:48 PM
Post: #49
RE: Looking for TVM contributions
(06-15-2024 02:36 PM)Albert Chan Wrote:  Newton's method, with a single point, f and f' need to be accurate.
We only need accurate f/f', but I don't know how to get that without good f, f'.

Code:
npmt = k*pmt - (pv + fv*s)*j/r;      // k=1+j*b, s=(1+j)^-n, r=s-1

pv and fv normally are big, likely opposite sign, (pv+fv*s) may have cancellation issue.
But, (pv+fv), (pv-fv), (pv+pmt), (fv-pmt) probably OK

k = 1+j*b, for b=1, also may lose precision.

npmt = (1+j*b)*pmt - (pv + fv*(r+1))*j/r = pmt + j*b*pmt - j*fv - (pv+fv)*j/r

npmt = (-(pv+fv)/r - (fv-b*pmt))*j + pmt
npmt' = -(pv+fv)/r*(1+n*(r+1)/(r+r/j)) - (fv-b*pmt)

Or, if you prefer, its time-symmetric version, where R = subst(r, n=-n)
This setup coded for HP71B (with test samples), and seems to work well.

npmt = ((pv+fv)/R + (pv+b*pmt))*j + pmt
npmt' = (pv+fv)/R*(1-n*(R+1)/(R+R/j)) + (pv+b*pmt)

Thanks. I have already used, tested and compared (offline) the "original formula" as had mentioned in a previous post and didn't find it that different in terms of results. I did that to make sure I'm not injecting unnecessary calculation errors. I'm aware of such numerical problems and the differences pertaining cancellations and roundoff.

Sorry to disappoint, but Secant still wins with smallest FVerror (the losing values are marked red):

.pdf  tvmperfcomp-formulas.pdf (Size: 41.84 KB / Downloads: 3)

These results are with Newton g=4 but g=5,6 are the same as it bottoms out so I stuck to g=4 for now. The first column is Newton with the "simpler" formulas of npmt and npmt' I've used before, the next column is Newton with the above formulas in your post. The third column is Secant with the simpler npmt formula.

The edge case of a tiny rate to branch is not the culprit, but it does badly affect this single test case for Newton when Secant is OK:

n=480.000000 pv=100000.000000 pmt=-208.333333 fv=0.000000
=> I%=0% FVerror=540000

I also implemented a prototype hybrid algorithm. This uses g=3 (g=2 is not as good). Here compared to Secant (with g=2) it performs well:

.pdf  tvmperfcomp-hybrid.pdf (Size: 37.14 KB / Downloads: 2)

The number of evals is between Newton and Secant, which is to be expected. The FVerror looks alright, a bit better than Newton and a little less good than Secant. But this is preliminary. There is some room for improvement.

- Rob

"I count on old friends to remain rational"
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Looking for TVM contributions - dm319 - 05-12-2024, 06:58 PM
RE: Looking for TVM contributions - dm319 - 05-12-2024, 08:48 PM
RE: Looking for TVM contributions - dm319 - 05-12-2024, 08:49 PM
RE: Looking for TVM contributions - dm319 - 05-12-2024, 08:00 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 11:04 AM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 05:58 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 05:59 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 08:34 PM
RE: Looking for TVM contributions - dm319 - 05-14-2024, 08:31 PM
RE: Looking for TVM contributions - dm319 - 05-15-2024, 01:00 PM
RE: Looking for TVM contributions - dm319 - 05-15-2024, 12:57 PM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 10:05 PM
RE: Looking for TVM contributions - dm319 - 05-25-2024, 01:43 PM
RE: Looking for TVM contributions - dm319 - 05-25-2024, 08:40 PM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 11:22 AM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 02:58 PM
RE: Looking for TVM contributions - dm319 - 05-24-2024, 09:22 PM
RE: Looking for TVM contributions - dm319 - 06-02-2024, 02:46 PM
RE: Looking for TVM contributions - robve - 06-09-2024, 02:04 AM
RE: Looking for TVM contributions - dm319 - 06-09-2024, 12:15 PM
RE: Looking for TVM contributions - robve - 06-09-2024, 03:29 PM
RE: Looking for TVM contributions - dm319 - 06-09-2024, 06:05 PM
RE: Looking for TVM contributions - dm319 - 06-09-2024, 10:00 PM
RE: Looking for TVM contributions - robve - 06-12-2024, 08:48 PM
RE: Looking for TVM contributions - robve - 06-14-2024, 03:23 PM
RE: Looking for TVM contributions - robve - 06-14-2024, 10:11 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 03:54 AM
RE: Looking for TVM contributions - dm319 - 06-12-2024, 11:56 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 03:05 AM
RE: Looking for TVM contributions - robve - 06-15-2024 05:48 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 09:52 PM
RE: Looking for TVM contributions - robve - 06-15-2024, 01:38 PM
RE: Looking for TVM contributions - robve - 06-16-2024, 05:18 PM
RE: Looking for TVM contributions - Werner - 06-17-2024, 05:11 PM
RE: Looking for TVM contributions - robve - 06-16-2024, 08:26 PM
RE: Looking for TVM contributions - dm319 - 06-16-2024, 11:55 PM
RE: Looking for TVM contributions - robve - 06-17-2024, 09:03 PM
RE: Looking for TVM contributions - robve - 06-18-2024, 03:27 AM
RE: Looking for TVM contributions - robve - 06-19-2024, 12:57 AM
RE: Looking for TVM contributions - robve - 06-19-2024, 02:01 AM
RE: Looking for TVM contributions - robve - 06-19-2024, 03:47 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 04:03 AM
RE: Looking for TVM contributions - robve - 06-20-2024, 05:07 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 04:30 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 06:27 PM
RE: Looking for TVM contributions - robve - 06-20-2024, 02:33 AM
RE: Looking for TVM contributions - robve - 06-21-2024, 09:04 PM
RE: Looking for TVM contributions - robve - 06-22-2024, 08:00 PM
RE: Looking for TVM contributions - robve - 06-23-2024, 06:03 PM
RE: Looking for TVM contributions - dm319 - 07-05-2024, 09:39 PM
RE: Looking for TVM contributions - dm319 - 07-05-2024, 09:44 PM



User(s) browsing this thread: 8 Guest(s)