mortage with monthly payment - mathematical modeling $Question:$ Suppose that $x_n$ is the amount owed on a mortgage after n years, $\$m$ is the monthly repayment and $r$ is the annual percentage interest rate charged on the amount of the mortgage outstanding.
(i) Derive a difference equation satisfied by $x_n$.
(ii) Solve the difference equation derived in (i) for a loan of $\$M$ to be repaid over $N$ years and hence determine what the monthly payment should be.
(iii) If the interest rate is $5\%$, show that the monthly repayment on a loan of $\$50,000$ to be repaid over $25$ years is $\$295.64$.
(iv) What is the total amount paid back on the loan?
$My$ $answer$ $so$ $far:$
(i) Let $\$m=x_0$. We need to derive an equation for $x_n$ which will be the amount owed after $n$ years. Thus, $x_0$ is the loan amount owed after $0$ years.
So we know that $x_{n-1}$ is the amount owed from the previous year. Also, $x_n$ (the amount owed for the $n_{th}$ year) is related to $x_{n-1}$ (the amount owed for the previous year).
$$x_n = f(x_{n-1}) = x_{n-1} + adjustments$$
We make $12$ monthly payments of $m$, so we substract $12m$:
$$x_n =x_{n-1} -12m + adjustments$$
Then we are charged $r$ times the amount owed the previous year:
$$x_n = x_{n-1} - 12m + r x_{n-1}$$
and hence,
$$x_n=(1+r)x_{n-1} - 12m$$
However, I assume my answer is incorrect as I can't find a way to turn it into a difference equation.
Any help would be appreciated.
 A: I'll show (i).  After the first month, the amount owed, $y_1$, is
$$y_1 = x_n \left (1+\frac{r}{12}\right ) - m$$
$$y_2 = y_1 \left (1+\frac{r}{12}\right ) - m = x_n \left (1+\frac{r}{12}\right )^2 - m \left (1+\frac{r}{12}\right ) - m$$
$$y_3 = y_2 \left (1+\frac{r}{12}\right ) - m = x_n \left (1+\frac{r}{12}\right )^3 - m \left [ \left (1+\frac{r}{12}\right )^2 + \left (1+\frac{r}{12}\right ) +1\right ]$$
$$\cdots$$
$$y_{12} = y_{11} \left (1+\frac{r}{12}\right ) - m = x_n \left (1+\frac{r}{12}\right )^{12} - m \left [ \left (1+\frac{r}{12}\right )^{11}+\cdots + \left (1+\frac{r}{12}\right ) +1\right ]$$
Summing the geometric series, we get
$$x_{n+1} = \left (1+\frac{r}{12}\right )^{12} x_n - 12 m \frac{\left (1+\frac{r}{12}\right )^{12}-1}{r}$$
(ii) Show that a solution to a difference equation of the form $x_{n+1} = a x_n+b$ is
$$x_n = A a^n + \frac{b}{1-a}$$
where $A$ is determined from an initial condition.  What is the initial condition here?  Then set the expression for $x_n$ to $0$ and solve for $m$.
(iii) Plug in the number into the above.
(iv) Multiply the monthly payment times $25 \cdot 12$.
