Request TVM formula guidance
|
12-11-2014, 06:36 PM
(This post was last modified: 12-14-2014 12:52 AM by Dieter.)
Post: #6
|
|||
|
|||
RE: Request TVM formula guidance
(12-11-2014 10:02 AM)iMatt04bit Wrote:(12-03-2014 09:17 PM)Dieter Wrote: Even with very small values of i ?-)It works with an interest value entry of 0.005/12, and up to 999/12. That's not "small". ;-) Try something like 1E-14/12. Or anything that rounds to 1 if you evaluate 1+R. Quote:I am very interested in applying the two functions you mention. These functions, ln1+x and e^x-1 have been discussed several times here. The classic method by W. Kahan for ln1+x can be found in the HP15C advanced functions handbook, others have been discussed in this forum, for instance here. Quote:I found the real one and its working well. If you consider the way Newton's method works, it's well possible that a slightly wrong derivative may work better (or worse) than the correct one. Quote:I really hope this is the right way, it seemed so from examples I have reviewed. Let's take a look at your example. Quote:For an initial value/guess of i, there is a set of conditional code statements which calculates an estimate depending on variations of the TVM inputs of PV,PMT,FV and if all are non-zero, or if one of them is zero, and also per signs. The estimates are within 0.5 of the solution at times, and aimed slightly above the expected value of i. Does this mean the estimate is off by 50% or by 0.5%? The latter would be sensational. ;-) Quote:I save the prior value of computed interest, payment, and the result of the TVM formula in fxA. The differences of these values are compared on each iteration. When little or no difference it is time to break out of the loop. Please see my previous post on this question. Now let's take a look at your example case. I have removed most of the data and left only x, the current approximation for the interest rate. Code:
WHAT? FIFTY-SEVEN ITERATIONS? #-) You must be kidding. There's definitely something going wrong here. I tried the quick-and-dirty spreadsheet I once used to estimate an initial guess for the interest rate. My first guesses for this case were 9,836% and 60%. Starting with these, the iteration converges as follows. The third column shows the results for your estimate 60,2% which works equally well. Code:
As you can see, the approximation converges after five resp. four (!) iterations. So it looks like there is something wrong with your iteration loop. Your initial guess of 60,2% is fine and converges within four iterations as well, so there must be something wrong within the loop. Convergence should develop roughly quadratic, and this is true for the example above. Take a look at the right column starting at 60,2%. The first approximation has two correct digits, the next one four, then eight and finally all 15 digits are correct. The left column shows the same pattern: the first approximation has 1–2 valid digits, and then three, six, twelve and finally all digits are correct. You may check whether the derivative is really correct by comparing its results with a numeric approximation: calculate f(r) and f(r+0,0001) and divide the difference of these two by 0,0001. Addendum: It looks like both your f(r) and f'(r) are not correct. Starting with 60,2%, the TVM equation (fxA) should return a value of 4,2065 and not 42,065 as stated in your results. Also the first derivative at this point (fxB) is roughly 56,81 and not 14,581. The correct values lead to a first approximation of 0,602 – 4,2065/56,81 = 0,52795... or 52,8%. The second iteration then should give fxA = –0,234 and fxB = 62,97 which leads to a new x of 53,17% – which is already exact to four significant digits. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)