User:Lovepeacejoy404/sandbox

Mathematical treatment
At time t = 0 a loan of an amount $$P_{0}$$ is disbursed. This sum is repaid with constant installments of amount R paid starting from time t = 1, therefore if we consider the year as a unit of measurement then R is the annual installment. Indicating with r the constant interest rate with which the interest on the residual debt is calculated $$ P_{t} $$ we have that:
 * $$\ P_{t+1}=P_{t} + rP_{t} - R =(1+r)P_{t} - R$$

Calculating $$ P_{1} $$ i.e. the loan after 1 year is:
 * $$\ P_{1}=(1+r)P_{0} - R $$

Calculating $$ P_{2} $$ i.e. the loan after 2 year is:
 * $$\ P_{2}=(1+r)P_{1} - R =(1+r)^{2}P_{0}-R(1+r)-R$$

Calculating $$ P_{3} $$ i.e. the loan after 3 year is:
 * $$\ P_{3}=(1+r)P_{2} - R =(1+r)^{3}P_{0}-R(1+r)^{2}-R(1+r)-R$$

Therefore the loan at time t will be:
 * $$\ P_{t}=(1+r)P_{t-1} - R =(1+r)^{t}P_{0}-R(1+r)^{t-1}-....-R(1+r)^{2}-R(1+r)-R$$

Place:
 * $$\ S_{t}=:-R(1+r)^{t-1}-....-R(1+r)^{2}-R(1+r)-R $$

We rewrite $$ P_{t} $$ like:
 * $$\ P_{t} = (1+r)^{t}P_{0} + S_{t}$$

Multiplying both sides of the equation $$ S_{t} $$ for $$ -(1+r) $$  we have:
 * $$\ -(1+r)S_{t}=R(1+r)^{t}+....+R(1+r)^{3}+R(1+r)^{2}+R(1+r) $$

By adding the 2 equations member by member, we obtain:
 * $$\ S_{t}-(1+r)S_{t}=R(1+r)^{t}-R $$

From which we obtain:
 * $$\ S_{t} = -\dfrac{R}{r}\left((1+r)^{t}-1\right) $$

Then the loan at time t is equal to:
 * $$\ P_{t}=(1+r)^{t}P_{0} + S_{t}=(1+r)^{t}\left( P_{0}-\dfrac{R}{r}\right) + \dfrac{R}{r} $$

Considering the succession $$ P_{t} $$ continuous if you can calculate the derivative to see when it is increasing or decreasing. Therefore it turns out:

$$\ \dfrac{d(P(t))}{dt}=(1+r)^{t}log(1+r)\left( P_{0}-\dfrac{R}{r}\right) $$

whereby the derivative is positive and the function is increasing by $$ R<=P_{0}r $$ and therefore in this case the loan would never be extinguished, while for $$ R>P_{0}r $$  the derivative is negative, the function is decreasing so that after a certain time the loan is extinguished. Wanting to calculate after how long the loan expires, the condition must be imposed:


 * $$ P_{t}=(1+r)^{t}\left( P_{0}-\dfrac{R}{r}\right) + \dfrac{R}{r}=0 $$

from which the exponential equation is obtained:
 * $$(1+r)^{t_{*}}=\left(\dfrac{R}{R-P_{0}r} \right)  $$

therefore passing to the logarithms we obtain that the time $$ t_{*} $$ i at which the loan is extinguished is:


 * $$ t_{*}=\dfrac{\log\left(\dfrac{R}{R-P_{0}r}\right)}{\log(1+r)} $$

while the annual installment to pay off the loan in an annual time $$t_*$$ at interest rate r is:


 * $$R=\frac{{P_0} r\, {{\left( r+1\right) }^{t_*}}}{{{\left(r+1\right) }^{t_*}}-1}$$

Using the wxMaxima program to calculate the monthly payment of a loan of € 100,000 at the rate of 2% over 20 years, a monthly payment of € 505.88 is obtained:

Using the wxMaxima program to calculate the years required for a loan of € 136,000 at the rate of 3.5% with a monthly payment of € 616, we obtain a time of 30 years:

Finally, wanting to calculate the annual interest rate of a loan of € 136,000 with a monthly payment of € 616 for 30 years, using wxMaxima both real and complex solutions are obtained but only the real positive one must be considered, which is equal to r = 0.035 i.e. r = 3.5%: