Request TVM formula guidance
|
12-03-2014, 09:17 PM
(This post was last modified: 12-03-2014 09:33 PM by Dieter.)
Post: #4
|
|||
|
|||
RE: Request TVM formula guidance
(12-02-2014 05:33 AM)iMatt04bit Wrote: The results appear precise and a match to a variety of real and simulated calculators. Even with very small values of i ?-) Some HP calculators use special functions like ln(1+x) or exp(x)-1 to ensure exact results even under these circumstances. Have you implemented something similar in Java? What's the working precision? Standard double precision, i.e. approx. 15 decimal digits? (12-02-2014 05:33 AM)iMatt04bit Wrote: I just need to know if I have a correct derivative. ...if only I had taken Calculus... If you didn't there is always Wolfram Alpha. ;-) (12-02-2014 05:33 AM)iMatt04bit Wrote: // formula from the hp12c manual, solves to 0 for matched I converted to R, used below I assume you mean f(R), not f(x). (12-02-2014 05:33 AM)iMatt04bit Wrote: // the derivative as best I know Hmmm... not quite. ;-) (12-02-2014 05:33 AM)iMatt04bit Wrote: // compute for +I Could you explain this a bit more in detail? And what about cases with, say, two different positive solutions? What is the initial guess for i, what value does the iteration start with? How do you handle cases where no solution exists? (12-02-2014 05:33 AM)iMatt04bit Wrote: // breakpoint on difference of prior computed I and current I is <= 5e-12 for fractional I | I < 1 percent Sorry, I do not quite understand what you want to say here. The usual exit condition for the iteration loop is a relative (!) error near the working precision, i.e. here 1E-15. Due to numeric pitfalls this may not occur under some circumstances, so I often use another idea: Since approach Newton's method converges roughly quadratically, the idea is to quit as soon as a relative error as small as, say, 1E-10 is reached. Assuming quadratic convergence, this means that the next iteration would have an error as low as 1E-20 and thus the approximation of i would not change — so you're done and the result is fine. Just an idea... Finally, here are two links that may be helpful: First you may take a look at the way the TVM equation is solved in the HP41 standard application pac. The code can be found in the HP41 software section. Hint: R07 holds 1+i%/100 and R09 stores i%/100. And finally, as you might have expected, the TVM issue has been discussed numerous time before. Maybe a look at this thread in the old forum may provide some useful information. Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 3 Guest(s)