Post Reply 
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)
If the denominator becomes zero, simply use
Code:
i0 = 2 / (n±1)
instead.

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
0: 0,1764705882   0,1304347826
1: 0,1448795054   0,1037633008
2: 0,1443589083   0,1020575265
3: 0,1443587133   0,1020509808
4: 0,1443587133   0,1020509807

Of course you may also simply start at i0 = 10–4.
The subsequent approximations then are essentially the same as listed above. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
41C/CV root finders - Dave Britten - 05-20-2015, 07:07 PM
RE: 41C/CV root finders - Thomas Klemm - 05-20-2015, 07:36 PM
RE: 41C/CV root finders - Dieter - 05-20-2015, 07:44 PM
RE: 41C/CV root finders - Dave Britten - 05-20-2015, 08:08 PM
RE: 41C/CV root finders - Massimo Gnerucci - 05-20-2015, 08:40 PM
RE: 41C/CV root finders - Dave Britten - 05-20-2015, 08:49 PM
RE: 41C/CV root finders - Didier Lachieze - 05-21-2015, 11:12 AM
RE: 41C/CV root finders - Dieter - 05-21-2015, 11:40 AM
RE: 41C/CV root finders - Dave Britten - 05-21-2015, 12:51 PM
RE: 41C/CV root finders - Dieter - 05-21-2015, 07:36 PM
RE: 41C/CV root finders - Dieter - 05-22-2015, 08:34 AM
RE: 41C/CV root finders - bshoring - 05-27-2015, 10:09 PM
RE: 41C/CV root finders - Dieter - 05-27-2015, 11:16 PM
RE: 41C/CV root finders - Ángel Martin - 05-28-2015, 06:19 AM
RE: 41C/CV root finders - Dieter - 05-28-2015, 08:42 AM
RE: 41C/CV root finders - bshoring - 05-28-2015, 09:37 PM
RE: 41C/CV root finders - Ángel Martin - 05-22-2015, 01:14 PM
RE: 41C/CV root finders - Dieter - 05-22-2015, 07:07 PM
RE: 41C/CV root finders - Dieter - 05-24-2015, 07:10 PM
RE: 41C/CV root finders - Ángel Martin - 05-25-2015, 05:35 AM
RE: 41C/CV root finders - Dieter - 05-25-2015, 07:19 PM
RE: 41C/CV root finders - Ángel Martin - 05-26-2015, 05:06 AM
RE: 41C/CV root finders - Dieter - 05-26-2015, 05:39 PM
RE: 41C/CV root finders - Ángel Martin - 05-26-2015, 09:26 PM
RE: 41C/CV root finders - Dieter - 05-26-2015, 10:08 PM
RE: 41C/CV root finders - rprosperi - 05-27-2015, 12:30 AM
RE: 41C/CV root finders - Dieter - 05-27-2015, 11:08 PM
RE: 41C/CV root finders - Ángel Martin - 05-28-2015, 05:44 AM
RE: 41C/CV root finders - Dieter - 05-28-2015, 09:50 PM
RE: 41C/CV root finders - Ángel Martin - 05-29-2015, 07:58 AM
RE: 41C/CV root finders - Ángel Martin - 05-27-2015, 05:17 AM
RE: 41C/CV root finders - Dieter - 05-27-2015, 01:50 PM
RE: 41C/CV root finders - Ángel Martin - 05-27-2015, 03:03 PM
RE: 41C/CV root finders - Dieter - 05-27-2015 07:15 PM
RE: 41C/CV root finders - Dieter - 05-28-2015, 09:59 AM
RE: 41C/CV root finders - Ángel Martin - 05-28-2015, 11:27 AM
RE: 41C/CV root finders - Ángel Martin - 05-28-2015, 01:54 PM
RE: 41C/CV root finders - Dieter - 05-28-2015, 06:33 PM
RE: 41C/CV root finders - Ángel Martin - 05-29-2015, 08:04 AM
RE: 41C/CV root finders - Ángel Martin - 05-29-2015, 05:54 PM
RE: 41C/CV root finders - Dieter - 05-29-2015, 06:15 PM
RE: 41C/CV root finders - Ángel Martin - 05-29-2015, 06:44 PM
RE: 41C/CV root finders - Dieter - 05-29-2015, 07:19 PM
RE: 41C/CV root finders - Dieter - 05-30-2015, 12:37 PM
RE: 41C/CV root finders - Ángel Martin - 05-30-2015, 02:04 PM
RE: 41C/CV root finders - Dieter - 05-29-2015, 08:00 PM



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