Post Reply 
Request TVM formula guidance
12-17-2014, 01:21 PM (This post was last modified: 12-17-2014 10:48 PM by Dieter.)
Post: #9
RE: Request TVM formula guidance
(12-17-2014 01:56 AM)iMatt04bit Wrote:  I am using the following formulas, where x is the interest rate in the form displayed on the calculator.

I have not checked this yet.
But how fast does it converge (# iterations) and which initial guess do you use?

(12-17-2014 01:56 AM)iMatt04bit Wrote:  I feel like the Newton method loses resolution for extremely small numbers, like 0.005/100 for an interest rate or smaller.

That's not the fault of Newton's method. Expressions like (1+i)n – 1 cause severe roundoff errors if implemented the way you did, i.e. with standard math functions like pow or exp.

(12-17-2014 01:56 AM)iMatt04bit Wrote:  So for an alternative I am experimenting with the Secant method (I have it working). Wiki is such a great resource.

Methods like the secant method or Regula Falsi work fine if there are two initial approximations that bracket the true root with different signs of the function to solve, i.e. f(x1) * f(x2) < 0. How do you make sure this condition is met, and what are the two guesses you start with?

(12-17-2014 01:56 AM)iMatt04bit Wrote:  There are an impressive amount of root finder methods out there, so its hard to know what others may prove useful for an alternative. I think a primary concern is the difficulty in solving small numbers that approach zero.

Again, that problem that can be addressed with a careful implementation. I will give an example. For the moment let's assume 15 digits working precision.

Code:

  let   i  =  1E-10%
        n  =  10 years with 12 payments/yr
  then
              r  =  8,3333 33333 33333 E-14
            1+r  =  1,0000 00000 00008
   (1+r)^120     =  1,0000 00000 00960
   (1+r)^120 - 1 =  9,6000 00000 00000 E-12
 
compare this with the true result:
 
   (1+r)^120 - 1 =  1,0000 00000 00496 E-11
 

Do the same calculation with 12 digits and 1+r will even numerically equal 1, leading to a plain zero.

These problems can be avoided by using the already mentioned special functions ln(1+x) and ex–1. These are also available in Java as log1p and expm1. So you better do the above calculation this way:

Code:

              r  =  8,3333 33333 33333 E-14
       log1p(r)  =  8,3333 33333 33298 E-14
       120 * "   =  9,9999 99999 99958 E-12
       expm1(")  =  1,0000 00000 00496 E-11
 

Of course this implementation is strongly recommended for any solving method.

Dieter

Edited to correct some typos
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Request TVM formula guidance - iMatt04bit - 12-02-2014, 05:33 AM
RE: Request TVM formula guidance - Dieter - 12-03-2014, 09:17 PM
RE: Request TVM formula guidance - Dieter - 12-11-2014, 06:36 PM
RE: Request TVM formula guidance - Dieter - 12-14-2014, 04:24 PM
RE: Request TVM formula guidance - Dieter - 12-17-2014 01:21 PM
RE: Request TVM formula guidance - Dieter - 12-21-2014, 06:14 PM
RE: Request TVM formula guidance - Dieter - 12-25-2014, 12:42 PM
RE: Request TVM formula guidance - Dieter - 12-29-2014, 07:47 PM



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