# Calculate interests

Simply wants to calculate interests of an initial amount $N$, with a monthly payback $m$, and a year interest rate of $R$

I guess the interests are not cumulated each month, but just at the end of the year.
Yet each month the total amount is decremented of 1 payback.
So it does $(N-6m)R$ interests at the end of the first year

2nd year initial amount: $N-12m+(N-6m)R$
2nd year interests: $(N-18m+(N-6m)R)R$

(... while the amount is positive)

I don't find any easy way to recurse it, if it's possible?

# Edit

so with $r=R/12$

1st month interests: $(Nr) +$
2nd month interests: $(N-m+Nr)r +$
3rd month interests: $( (N-m+Nr)(1+r) -m )r +$
4th month interests: $( (N-m+Nr)(1+r)^2 -m(1+r) -m )r +$
5th month interests: $( (N-m+Nr)(1+r)^3 -m(1+r)^2 -m(1+r) -m )r +$
6th month interests: $( (N-m+Nr)(1+r)^4 -m(1+r)^3 -m(1+r)^2 -m(1+r) -m )r +$
...
xth month interests: $( (N-m+Nr)(1+r)^x -m((1+r)^x-1)/r )r$
$= (Nr-m)(1+r)^{i+1} +m$
$= I(x)$

so the loan interests after x months could be calculated with:

$\sum_{1..x} \ I(y) = (x-1)m+(Nr-m)(1+r)^2((1+r)^x-1)/r$

but not sure if it's correct...

the yth month intial amount is $I(y)/r = 1/r*( (1+r)^{y+1} *(Nr-m) +m)$ that helps to know when the loan is finished

@Limitless I'm going to check if it gives same result with your answer

-
Yes, one can get recurrences, and explicit formulas. But the problem is not completely described. Is $r$ the nominal yearly rate? Is interest compounded monthly? What are we trying to calculate? – André Nicolas Dec 2 '12 at 0:45
My answer attempts to interpret your answer as mathematically reasonable as possible, but I do not know if my interpretation of your question mirrors your thinking. In any event, I hope it is useful. – 000 Dec 2 '12 at 1:32
@AndréNicolas I thought when you do a loan, the interests were added at the end of the year only, but it's probably each months, it would increase slightly the result. yes r is the nominal interest rate (e.g. 2.5%), @ Limitless thx trying to understand it – crl Dec 2 '12 at 1:41
Are you saying $r$ represents the interest paid to you for every year and $m$ is the amount taken out of the account every month? – 000 Dec 2 '12 at 1:47
yes r: yearly interests of the loan and m: monthly payback, @AndréNicolas I have edited the question with what you suggested can you have a look? – crl Dec 2 '12 at 15:26

Let $V(y,b;N,m,r)$ calculate the value of the interest of an initial amount of money, $N$, put into an account on the $b$th month with a monthly payback of $m$ and a yearly interest rate of $r$ at the end of the $y$th year.

Naturally, for $V(0,b;N,m,r)$ we have $N$ since this is just the initial amount and $0$ years have passed. At the end of year one, we have $N+(N-(12-b)m)r=N+(N-12m+bm)r$. This is because the money is put in at the $b$th month and $(12-b)$ months remain in the year. Thus, we have $(12-b)$ monthly paybacks, and that is where we get $(N-(12-b)m)$. Given that $(N-(12-b)m)$ is the yearly balance in the account at the end of the year, it accrues an interest of $(N-(12-b)m)r$. Thus, the total value at the end of the year is that (the interest accrued) added to the original, so we have $N+(N-(12-b)m)r=N+(N-12m+bm)r$.

For the end of the second year, we have $N+(N-12m+bm)r+[N+(N-12m+bm)r-12m]r$. If we let $N_1=N+(N-12m+bm)r$, this makes much more sense: $$N+(N-12m+bm)r+[N+(N-12m+bm)r-12m]r=N_1+[N_1-12m]r;$$ that is, it's simply the amount of year one, $N_1$, plus the interest accrued after the $12$ monthly paybacks (the interest accrued being the $[N_1-12m]r$).

For the end of the third year, we have $N_1+[N_1-12m]r+(N_1+[N_1-12m]r-12m)r$. In other words, if we let $N_y=V(y,b;N,m,r)$, our recurrence becomes almost obvious: $N_x=N_{x-1}+(N_{x-1}-12m)r$. So, your recurrence is:

$$V(y,b;N,m,r)=V(y-1,b;N,m,r)+\left[V(y-1,b;N,m,r)-12m\right]r,$$ or, using the $N_y$ notation, $$N_x=N_{x-1}+(N_{x-1}-12m)r.$$

To solve the recursion, I first put it into a nicer form: $$N_x=N_{x-1}+rN_{x-1}-12mr=(1+r)N_{x-1}-12mr.$$ Now, let $C=-12mr$ and $u=1+r$. We have, then, $$N_{x}=(1+r)N_{x-1}-12mr=uN_{x-1}+C.$$

As we continue putting the recursion inside itself, we see a pattern:

\begin{align} N_x&=uN_{x-1}+C\\ &=u(uN_{x-2}+C)+C\\ &=u^2N_{x-2}+uC+C\\ &=u^2(uN_{x-3}+C)+uC+C\\ &=u^3N_{x-3}+u^2C+uC+C\\ &=\dots \end{align}

In other words, we're noticing that if we continue this until we're at $N_2$, we have (note: we're not going all the way back to $N_1$ or $N_0$ since this pattern begins at $N_2$):

$$N_x=u^{x-2}N_{2}+\left(\sum_{0 \le i \le x-3}u^i\right)C.$$

The sum has a closed form since it is the canonical geometric sum. Its closed form is simply $\frac{1-u^{x-2}}{1-u}$. Thus, we have: $$N_x=u^{x-2}N_2+\left(\frac{1-u^{x-2}}{1-u}\right)C.$$

After subbing back in and completing some simplifications, we finally arrive at

$$N_x=(1+r)^{x-2}N_2+12((1+r)^{x-2}-1)m.$$

Now, recalling that $N_2=N_1+(N_1-12m)r$ and $N_1=N_0+(N_0-bm)r$, we have $N_2=N_0+(N_0-bm)r+(N_0+(N_0-bm)r-12m)r$. This is more compactly stated as $$N_2=N_0+\left((2+r)N_0-(b+br+12)m \right)r.$$

Subbing $N_2$ in, our final statement is thusly:

$$V(y,b;N,m,r)=(1+r)^{x-2}\left[N_0+\left((2+r)N_0-(b+br+12)m \right)r\right]+12((1+r)^{x-2}-1)m.$$

## Remark

[. . .]it does (N−6m)r interests at the end of the first year

It would appear that your case is $b=6$. Throw that into the above formula and it simplifies a tad.

-
seems x and y are mixed, it's V(x,b... ) above? – crl Dec 2 '12 at 1:47
@ca11111, yes. That was intentional. I use $y$ at first since $y$ is in $V(y,b;N,m,r)$. However, I wanted to define a recurrence relationship. So, because I see recurrence relationships and functions as separate and very different things, I used two different letters. The object being represented is inherently the same. However, since my expression of the concept changes, I use different letters. It is like how you mean the same object when you say two differently spelled synonyms. – 000 Dec 2 '12 at 1:52
ok else, to me, for the amount at beginning of years: $N_y = N_{y-1} - 12m + r(N_{y-1}-6m)$ no? (you have put $12m$ also multiplied by r) – crl Dec 2 '12 at 1:57
@ca11111, I don't think that's correct because the $-12m$ makes no sense to me. Why are 12 monthly payments being taken out if those 12 months haven't happened yet? My phrasing, that is, $N_x=N_{x-1}+(N_{x-1}-12m)r$, says the following English: At the $x$th year, the total amount of money is the previous year's initial amount plus the end of the previous year's amount times the interest rate. We have $N_{x-1}-12m$ as the previous year's amount at the end of the year because 12 months pass and 12 monthly payments are taken out. (continued below) – 000 Dec 2 '12 at 2:03
An important factor here, though, is that the statement $N_x=N_{x-1}+(N_{x-1}-12m)r$ only applies for the end of the second year ($x=2$) and onward. This is because the end of the first year complicates things with the $b$ variable. However, the bottom of the answer accounts for this and solves your problem nonetheless. – 000 Dec 2 '12 at 2:05