Request TVM formula guidance
|
12-14-2014, 04:24 PM
(This post was last modified: 12-14-2014 09:02 PM by Dieter.)
Post: #7
|
|||
|
|||
RE: Request TVM formula guidance
(12-11-2014 10:02 AM)iMatt04bit Wrote: // formula from the hp12c manual, solves to 0 for matched I converted to R, used below Since there seems to be something wrong with your iterative calculation, here's a first suggestion on how to handle the TVM function, its derivative and the iterative approximation. You may want to try it and see what you get. Here r is the (decimal) interest rate (e.g. 0.05 for 5%) and k is either 0 or 1, depending on END or BEGIN mode. Since the equations will try to divide by zero if r=0, it might be a good idea to provide a first guess for r which equals the approximation that would follow an estimate of r=0. I used the following formula: Code: r = 2 * (pv + n * pmt + fv) / ((fv * (2*k-1 + n) + pv * (2*k-1 - n))) – If r = 0 we're already done: r=0 is the exact solution. – If r > 0 we have a first approximation that will be improved during the following iteration loop. – If r < 0 using half that (r := r/2) as the initial guess seems to work better, especially for large n. Now the iteration may start. The TVM function and its derivate may be evaluated quite efficiently this way: Code: q = 1 + r Finally r is adjusted: Code: correction = TVMfunction / TVMderivative Repeat this until abs(correction) is sufficiently small, e.g. ≤ abs(1E-12 * r), or the max. number of iterations is ecceded (which means no convergence and should throw an error). For your example case this yiels the following results: Code: # Approximation for r TVM(r) / TVM'(r) = correction BTW the TVM equation may be written in numerous different ways. Some can be evaluated more easily, some less so, some provide faster convergence, others converge slower. So the way the TVM equation is shown in the 12C manual may not be the final word. ;-) Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 2 Guest(s)