Post Reply 
Some TVM fun
01-03-2024, 05:14 PM (This post was last modified: 01-03-2024 05:36 PM by bxparks.)
Post: #7
RE: Some TVM fun
I had a quick peak into Part IV, where I%YR is 0 or slightly negative. Two comments about how RPN83P handles that:

1) Negative I%YR: I set the 2 default initial guesses in the TVM Solver to be 0% and 100%, assuming that real life problems have positive interest rates, instead of deflationary negative interest rates. But I hadn't considered rounding or truncation errors which may push the solution to be slightly negative. So maybe I should set the guesses to be -1% and 100%? (Edit: The reason it fails to find a solution is because I coded the solver to be conservative, and bail out immediately if it does not detect a sign change using the initial root guesses.) I have tried hard to avoid dealing with negative interest rates because many expressions in the TVM equations blow up at -100%, and I don't have a full understanding of the mathematical and numerical properties of those expressions near -100%.

2) Accuracy When I%YR is Close to Zero: I have doubts about the numerical accuracy of the RPN83P TVM Solver when I%YR is close to 0%. Mostly because I'm not sure what the termination condition should be. Normally the root solver (I use the Secant Method) terminates when the relative difference between 2 successive candidate roots is less than some tolerance, specifically, abs((i2-i1)/i2) < 1e-8. But when the actual solution is 0 or close to it, we can suffer from a division by zero error. My current hack is to use an absolute error when i2==0, i.e. use abs(i2-i1) < 1e-8. But that becomes progressively less accurate when the actual root is less than around 1e-8 (Edit: Or does it only start becoming less accurate when i1 or i2 is < 1e-49 or 1e-99? Anyway, it's not ideal.)

Albert's post about switching to Taylor series expansion when (1+i^2 == 1) seems like the appropriate solution when i becomes close to zero. I don't have time to look at this now, as I'm spending all my free time towards a new release of RPN83P with complex numbers. I may get around to it afterwards. (On the other hand, coding complicated TVM equations in assembly language and doing manual stack juggling is so painful, I may not have the energy to come back to this until much much later.)
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Some TVM fun - dm319 - 01-01-2024, 10:12 PM
RE: Some TVM fun - Albert Chan - 01-02-2024, 12:51 AM
RE: Some TVM fun - Albert Chan - 01-02-2024, 01:47 PM
RE: Some TVM fun - dm319 - 01-02-2024, 07:37 PM
RE: Some TVM fun - Albert Chan - 01-02-2024, 08:16 PM
RE: Some TVM fun - dm319 - 01-03-2024, 01:08 PM
RE: Some TVM fun - bxparks - 01-03-2024 05:14 PM
RE: Some TVM fun - Albert Chan - 01-03-2024, 05:21 PM
RE: Some TVM fun - dm319 - 01-03-2024, 08:04 PM
RE: Some TVM fun - Albert Chan - 01-03-2024, 08:28 PM
RE: Some TVM fun - dm319 - 01-03-2024, 08:10 PM
RE: Some TVM fun - Albert Chan - 01-03-2024, 09:36 PM



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