Re: [WP34s et al.] Solving the TVM equation for the interest rate Message #15 Posted by fhub on 2 Dec 2012, 5:57 p.m., in response to message #14 by Dieter
Quote:
It's not trivial, but maybe easier than you think.
And OTOH maybe harder than you think.
I've tried your 2 examples above with ALL financial HP calculators/emulators (HP12c/10bII+/17bII+/30b and also the TVMsolver of the HP50g), and NONE of them returned any solution. So my TVM program for the WP34s is at least in good company. ;)
The main problem of the WP34s TVMprogram is that the implemented solver expands the initial interval for 'i' if the 2 guesses have the same sign, and with this expansion 'i' gets values that are just too small (maybe even <1) and so the program stops with an error message. Unfortunately I can't restrict the internal solver in any way, i.e. I can't tell him to not use too small negative 'i'values.
What I've tried so far is that you can manually enter a startvalue I0 when TVM returns an error: you enter this value for 'I' and then start the solving process for 'I' again. In this case (i.e. if I=I0<>0) the solver is called again with the interval [I05,I0+5]. When also this interval doesn't return a solution, I0 is automatically set to I0+10, so you simply have to repeat solving for 'I' (just 2 keypresses [A][B] in my 2nd TVM version). You can repeat this until you reach an interval with a solution in it.
This method is quite comfortable, and such problems occur only under very special and unrealistic conditions (as your examples).
I'm still thinking about to automate this process, i.e. maybe the program should automatically scan the interval [0%,100%] for 'I' in 10%steps (and eventually also for negative 'I') until it finds an interval with changing signs, so that the WP34s solver would definitely find the solution.
Your description above is really impressing, but there are 2 problems that I see:
First VERY much code would be necessary to make all those tests to differentiate between all those different cases, and then I still don't see any concrete value where a Newton method should start (for all those different cases) and would guarantee that a solution will be found. Just think of all those cases where the tangent is nearly horizontal, this would put the next iteration point VERY far away (probably giving any error messages again because of over/underflows etc.).
I (and maybe you, too) understand now why all TVM solvers of financial calculators fail under such special conditions.
Franz
Edited: 2 Dec 2012, 5:58 p.m.
