%% mortgages.tex
\documentstyle[12pt]{article}
\pagestyle{empty}
% \setlength\topmargin{-0.75in}
% \setlength\textheight{9.00in}

\setlength\topmargin{-0.50in}
\setlength\textheight{8.5in}
\begin{document}

\begin{centering}

{\Large Mortgage Interest \& Principal Payments}

\bigskip
{\Large Seth Teller}

\end{centering}

\vspace*{0.25in}
A few years ago, I bought a house, and got frustrated when 
the lending representatives were unable to explain
how they had arrived at particular mortgage payments
(all they could do was table lookups).  I was curious about 
how the amount of the fixed monthly payment is determined,
and how it gets partitioned into principal 
and interest -- so I derived it directly, as follows.

Suppose we wish to take a loan of $A$ dollars at yearly
interest rate $R$ (equivalently, monthly interest rate
$M = R / 12$) to be paid monthly over $Y$ years (in 
$N$ monthly payments, where $N = Y \cdot 12$).
The object of this problem is to determine the (constant) 
total monthly payment $T$, and its (varying) apportionment
between principal $P_k$ and interest $I_k$ (for the $k$-th
monthly payment).

\bigskip
{\bf \noindent Problem:}

Express $T$, $P_k$, and $I_k$ as functions of
$M$, $N$, and the loan amount $A$.

\bigskip
{\bf \noindent Solution:}

Define the balance after the $k^{th}$ payment as $B_k$.
Then 
$$
B_0 = A  \mbox{ \phantom{XXXX} and \phantom{XXXX} } B_N = 0
$$
Moreover, the first interest payment
will be on the entire loan amount:
$$
I_0 = M A
$$
and the sum of all the principal payments must 
equal the loan amount:
$$
\sum_{k=1}^{N}{P_k} = A
$$
The monthly payment $T$ is constant;
thus $T_{k-1} = T_k$ for any $k > 1$, and
$$
M(A - \sum_{j = 1}^{k-2}{P_j}) + P_{k-1} = 
M(A - \sum_{j = 1}^{k-1}{P_j}) + P_{k}
$$
Cancelling common terms yields
$$
P_k = (1+M) P_{k-1}
$$
so that
$$
P_N = (1+M)^{N-1} P_1
$$

\noindent
Now, consider the initial balance $A$ and sequence of $N$ payments

\bigskip \noindent
\begin{tabular}{|r|c|c|c|c|}
					 \hline
  k &	    $I_k$	     &	  $P_k$   &	$T$                   & $B_k$         \\ \hline
  0 &       	     &        &                     & A         \\ \hline
  1 &  $M A$	     & $P_1$  & $M A + P_1$         & $A - P_1$ \\ \hline
  2 &  $M (A - P_1)$ & $P_2$  & $M A - M P_1 + P_2$ & $A - P_1 - P_2$ \\ \hline
 $\cdots$ &  	     &		&			&	\\ \hline
  $N$ &  $M ( A - \sum_{k = 1}^{N-1}{P_k})$ 
    &  $P_N$ & $M ( A - \sum_{k = 1}^{N-1}{P_k}) + P_N$ 
    &  $A - \sum_{k = 1}^{N}{P_k}$ \\ \hline
\end{tabular}

\bigskip \noindent Since $\sum_{k = 1}^{N}{P_k} = A$, we can rewrite the last row
(i.e., the $N^{th}$ payment) as

\bigskip % \noindent
\begin{center}
\begin{tabular}{|r|c|c|c|c|}
					 \hline
   k &	  $I_N$	 &  $P_N$   &	$T$  & $B_N$         \\ \hline
%  $N$ &  $M ( A - \sum_{k = 1}^{N-1}{P_k})$ 
%    &  $P_N$ & $M ( A - \sum_{k = 1}^{N-1}{P_k}) + P_N$ 
%    &  $A - \sum_{k = 1}^{N}{P_k}$ \\ \hline
  $N$ & $M P_N$ &   $P_N$   & $(1 + M) P_N$ & 0 \\ \hline
\end{tabular}
\end{center}

\bigskip \noindent
Equating $T = T_1 = T_N$ and substituting for $P_N$ yields
$$
P_1 = \frac{M A}{(1 + M)^N - 1}
$$

\bigskip \noindent
We can now -- as specified by the problem statement -- express $T$, $P_k$, and $I_k$ solely as 
functions of $M$, $N$, and $A$:
$$
T = (1+M)^N P_1 = \frac{M A (1+M)^N}{(1 + M)^N - 1}
$$
\bigskip
$$
P_k = (1+M)^{k-1} P_1 = (1+M)^{k-1} \frac{M A}{(1 + M)^N - 1}
$$
\bigskip
$$
I_k = T - P_k
$$

\bigskip \noindent
Lenders, to avoid evaluating so many exponentiations, probably compute mortgage tables using the above
closed-form expression for $T$, the recurrence
$$
 B_0 = A 
 \mbox{;}\quad I_k = M B_{k-1}  
 \mbox{;}\quad P_k = T - I_k 
 \mbox{;}\quad B_k = B_{k-1} - P_k
$$
and some rule for rounding fractional values to whole pennies.

\bigskip
\noindent{(Note: see \verb+C+ code \verb+mortgage.c+ for an implementation.)}

\end{document}

