41C/CV root finders
|
05-27-2015, 07:15 PM
(This post was last modified: 05-27-2015 07:42 PM by Dieter.)
Post: #25
|
|||
|
|||
RE: 41C/CV root finders
(05-27-2015 03:03 PM)Ángel Martin Wrote: correct - it is divided by 100 ;-) I see. So the formula is abs(pv+n*pmt+fv)^(1/n) / 100. I tried this estimate for a number of different scenarios, and in most cases the result is somewhere between 1 and 2%. So one could just as well use a fixed estimate of 1%. Or did I get something wrong? (05-27-2015 03:03 PM)Ángel Martin Wrote: We're comparing apples to oranges - the number of MCODE loops are not exactly the same concepts as the iterations in the FOCAL code, sorry but that's not a one-to-one match. But why does it require so many iterations? And why is the result off in the last digits, although 13 digit extended precision is used? Sorry, I just want to understand. (05-27-2015 03:03 PM)Ángel Martin Wrote: Besides the MCODE speed is significantly faster... are you saying that your FOCAL program finds the solution *faster* than the 12C? No, of course not. #-) Although I do not own a 12C I assume its internal "machine code" runs much faster than my trusted 41C/CV. Here one iteration takes about two seconds, so the result for the test case appears in about 10 seconds. On the 35s it's about 3 seconds. And on the 34s it's virtually instant. (05-27-2015 03:03 PM)Ángel Martin Wrote: And you have achieved that, so which initial guess do you suggest I should try? I would suggest the formula at the bottom of post #13 in this thread. There you'll also find the other mathematics I use. However, cases may exist where the denominator of i0 becomes zero. So I would do it this way: Code: i0 = 2 / n * (PV + n*PMT + FV) / (PMT * (n±1) + 2*PV) Code: i0 = 2 / (n±1) In both cases use n–1 for END mode and n+1 for BEGIN. BTW, if the nominator is zero, i.e. i0 itself is zero, the program can exit: in this case the interest rate actually is zero. Exiting at this point also avoids the usual problems that arise when the TVM equation is evaluated at i=0. For the record, this is how i converges in the test case, using the suggested estimate and a simple FOCAL program with 10-digit precision: Code: # end mode begin mode Of course you may also simply start at i0 = 10–4. The subsequent approximations then are essentially the same as listed above. ;-) Dieter |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)