Capitalization of interest

119 Views Asked by At

I've got quiet a strange problem but a simple one I guess. So I have a starting sum of 10 and I would like to know how many years need to pass to achieve 30000 with 32% interest applied every 2 years. There's an equation for such problems:

K = Ko (1 + p / (100*m) )^(m*n)

where K is the target sum, Ko is the starting sum, p is the percent, m is how many times an interest is applied in a year and n is years. I took K = 30000, Ko = 10, p = 32, m = 1/2, n - the unknown. Following this pattern I got to such equation:

n = log_(sqrt(1,64)) (30000 / 10) = 32,36...

based sqrt(1,64) logarithm of (30000/10)

Secondly to check the correctness of this equation I've written a simple program in C++:

#include <stdio.h>
#include <conio.h>

int main()
{
    int total = 30000;
    int current = 10;
    int n = 0;

    while(current < total)
    {
        current = current * 1.32;
        n+=2;
    }
    printf("%d", n);
    _getch();
}

which gives me n = 60. I know this program is inaccurate and won't give a precise result but such difference between results proves that one solution must be wrong? The program is very simple and it seems to me correct so I guess that the mathematical formula above doesn't work in my case?

3

There are 3 best solutions below

2
On BEST ANSWER

Two problems.

Problem 1. You quote a formula K = Ko (1 + p / (100*m) )^(m*n) But the formula you're trying to implement should have (1 + p / 100) rather than (1 + p / (100*m)).

$$\begin{align} K &= K_0 ( 1+ p/100)^{mn} \\ \log\frac{K}{K_0} &= mn \log(1+p/100) \\ n &= \frac{1}{m}\frac{\log(K/K_0)}{\log(1+p/100)} \\ &= 2\frac{\log(30000/10)}{\log(1.32)} \end{align} $$

Evaluating 2*log(30000/10)/log(1.32) gives 57.67617, i.e. 58 rounded up to the nearest two years.

Problem 2. You use int in your program when you should use double. Once you correct your program, as below, you get 58 not 60 out of your program.

#include <stdio.h>

int main()
{
    double total = 30000;
    double current = 10;
    int n = 0;

    while(current < total)
    {
        current = current * 1.32;
        n+=2;
    }
    printf("%f final, %d", current, n);
}

(ideone online program)

0
On

The difference is in how "$32\%$ interest applied every $2$ years" is interpreted in the methods.

The compound interest formula is for a yearly rate. As in over a period of one year, if your interest was not compounded, how much would your money increase? The issue is that the rate you have is not a yearly rate. It's the rate for every two years.

Notice the $1.64$ you have there? That's $1+0.32\cdot2$. Put that into a two year period, where interest should only be applied once and not compounded at all yet. You expect $13.2$, but get $$\left(1+\frac{32}{100\cdot0.5}\right)^{0.5\cdot2}=1.64$$ You've doubled your rate. Use a rate of $16\%$, a yearly rate, and you get an answer of $57.68$ years. In reality it would be $58$, since you need to reach the next interest payout period.

As for why your program is getting $60$ instead of $58$, int casting rounds every payout down to the nearest dollar. You're losing a bit of money each time and the error, quite appropriately, compounds.

0
On

Answer:

Translating 32% every two years is equivalent to finding the yearly rate as below:

$$1.32 = (1+p)^2$$

$$p = (1.32)^{0.5} -1 = 0.1489125$$

Now simply apply the formula $K = K_0\left(1+p\right)^n$

Now $$n = \frac{log(\frac{K}{K_0})}{log(1.1489125)} = 57.67616963$$