$P = L*\frac{x*(1+x)^n}{(1+x)^n - 1}$
where
P - monthly payment
L - loan amount
x - monthly interest rate
n - number of payments
I answer my own question.
$P = L*\frac{x*(1+x)^n}{(1+x)^n - 1}$
where
P - monthly payment
L - loan amount
x - monthly interest rate
n - number of payments
I answer my own question.
On
Here is a second approach:
Let the interest rate per month be $x$ and the number of payments be $n$.
Just assume that each month $P$ is paid back to be bank but never discounted from the loan. They are just stored in the bank and create compound interests by themselves.
After $n$ instalments, the total sum of the amounts created by the the $n$ instalments is equal to the amount created by the loan $L$ after a period of $n$ instalments.
The debt is then settled directly.
Not sure whether I explain the concepts involved clearly. Hope that the following steps below help.
For the first $P$, after another $n-1$ payments, it amounts to $P(1+x)^{n-1}$.
For the second $P$, after another $n-2$ payments, it amounts to $P(1+x)^{n-2}$.
For the third $P$, it amounts to $P(1+x)^{n-2}$.
...
For the last but one $P$, it amounts to $P(1+x)$.
For the last $P$, it has no interest. Therefore it is just $P$.
Thus the total amount is $$P(1+x)^{n-1}+P(1+x)^{n-2}+ \cdots + P(1+x)+P=P\left(\frac{(1+x)^n-1}{x}\right) \tag{1}$$
On the other hand, after $n$ payments, the total amount created by the loan $L$ is $$L(1+x)^n \tag{2}$$
For a fair play, the amounts in $(1)$ and $(2)$ equate.
$$\therefore P\left(\frac{(1+x)^n-1}{x}\right)=L(1+x)^n$$ $$P=\frac{Lx(1+x)^n}{(1+x)^n-1}$$
OK. Let me state the problem here.
We have a loan amount $L$, number of payments $n$, interest rate per year $Y$. What will a monthly payment $P$ be?
Usually loan has interest rate per year $Y$ and payments made by month, so we need to convert $Y$ to monthly interest rate $x = \frac{Y}{12} (1)$.
Let's calculate the loan reminder after the 1st payment, we used all loan $L$ money for a month.
$L_1 = L*(1+x) - P (2)$
Let's calculate the loan reminder after the 2nd payment, we used the loan after the 1st payment $L_1$ money for a month. Use formula (2) to simplify and to open parenthesis.
$L_2=L_1*(1+x) - P = [L*(1+x) - P]*(1+x) - P = L*(1+x)^2 -P*(1+x) -P = L*(1+x)^2 -P*[(1+x) + 1] (3)$
Let's calculate the loan reminder after the 3rd payment, we used the loan after the 2nd payment $L_2$ money for a month. Use formula (3) to simplify and to open parenthesis.
$L_3=L_2*(1+x) - P = \{L*(1+x)^2 -P*[(1+x) + 1]\}*(1+x) - P = L*(1+x)^3 -P*(1+x)^2 - P*(1+x) -P = L*(1+x)^3 -P*[(1+x)^2 + (1+x) + 1] (4)$
We can see a pattern now and can write the expression for $L_n$.
$L_n=L_{n-1}*(1+x) - P = L*(1+x)^n - P*[(1+x)^{n-1}+ ... + (1+x)^2 + (1+x) + 1] (5)$
I also want to state that after last payment $L_n$ we are no longer own any amount on the loan. Or $L_n = 0 (6)$ or using (5) in (6)
$L*(1+x)^n - P*[(1+x)^{n-1}+ ... + (1+x)^2 + (1+x) + 1] = 0(6')$
Let's simplify $(1+x)^{n-1}+ ... + (1+x)^2 + (1+x) + 1$. We know from school mathematical curriculum about geometric progression. Each element of geometric progression can be expressed as
$a_k=a*r^{k-1}$ (6")
where $1 \le k \le K$ and $r$ is the denominator of the geometric progression.
and the sum of elements of geometric progression from $1$ to $k$ is calculated by formula
$S_k = a*\frac{1-r^k}{1-r}$ (6''')
It can be seen that $a=1$ and $r=(1+x)$, so $(1+x)^0, (1+x)^1, (1+x)^2, ..., (1+x)^{n-1}$. Let's apply the formula (6''') to our case: $(1+x)^{n-1}+ ... + (1+x)^2 + (1+x) + 1= 1* \frac{1-(1+x)^n}{1-(1+x)} = \frac{1-(1+x)^n}{1-1-x} = -\frac{1-(1+x)^n}{x}(7)$.
Now use (7) in (6')
$L*(1+x)^n - P* [-\frac{1-(1+x)^n}{x}]= 0 (8)$
Solving (8) to find $P$
$L*(1+x)^n = P* [-\frac{1-(1+x)^n}{x}] (8')$
$L*(1+x)^n = P* [\frac{(1+x)^n - 1}{x}] (8'')$
$P = L*[\frac{x*(1+x)^n}{(1+x)^n-1}](9)$
Here's the small piece of Python code to calculate monthly payment:
Test results:
Questions, comments, edits ?