We want to understand the relationships between the mortgage payment of a fixed rate mortgage, the principal (the amount borrowed), the annual interest rate, and the period of the loan. We are going to assume that payments are made monthly, even though the interest rate is given as an annual rate. So, one of the things we will need is a way to convert years into months. Let's define
For example, we can write
to determine the number of monthly payments made on a 30 year loan, and we can write
to convert an annual percentage rate of 8% into a monthly rate.
Now let's think about what happens with each monthly payment. Some of the payment is applied to pay the interest for that month, and the remainder is applied to reduce the principal. Let P denote the principal at the beginning of the month, let R denote the amount of the monthly payment, and let J denote the monthly interest rate.
This allows us to compute a formula for the new principal.
In order to understand the full relationship between the principal, interest rate, number of payments, and monthly payment, we need to see how the outstanding principal changes over the course of several payments. The simplest way to think about this relationship is to observe that the outstanding principal changes with each payment by the formula we just worked out for computing the new principal after one payment; we simply need to repeat this process. The next series of commands shows how to do this. (The curious double definition of the function outstanding[N] is a standard technique in Mathematica to make the function remember values that it has computed earlier. See Section 2.4.9 of The Mathematica Book by Steven Wolfram.)
For example, here is the amount of the principal still outstanding after each of the first six payments.
Next, we'll try to find a better formula for the outstanding principal. It's clear from our examples that there will always be a term of the form P. However, we need a better formula for the term involving R. The coefficients of powers of J in this term are reminiscent of the binomial coefficients. For example, we have
With a minor adjustment, we can get the exact term.
So, a formula for the outstanding principal is
Now suppose that after N payments the loan is paid off. Then the outstanding principal is zero. By setting outstandingPrincipal to zero and solving the resulting equation for R, we can compute the monthly payment as a function of the principal, interest rate, and number of payments.
For example, the payment on a loan of $150,000 at 8 percent for 30 years is
We may also want to determine the amount of money that can be borrowed as a function of the amount we are able to pay each month. We simply solve our equation for P in terms of the remaining variables.
For example, suppose we can afford to pay $1500 per month, and that the interest rate on a 30 year loan is 8 percent. Then the amount of money that can be borrowed is
As a final piece of the analysis, we are going to write a function that will produce a table of values showing how much of each of a series of payments is allocated toward the interest payment, and how much is used to reduce the principal. The function takes as inputs the initial principal, the annual interest rate, the monthly payment, and the number of payments to be made during the period of time covered by the table. We use the Mathematica commands Module and Do to write a function that can repeat a process a fixed number of times, using local variables to store the intermediate results of the computation.
Let's see what happens if we make one year's worth of $1100.65 payments on a $150,000 loan at an annual interest rate of 8 per cent.
Using similar techniques, we can determine the total amount of interest paid over the life of a loan. In order to do this, we need to know the principal, the interest rate, and the number of payments.
For example, let's continue to look at the case of a 30 year mortgage at eight percent. With a principal of
we pay a total interest of
Here is a pie chart showing the relative amounts paid in principal and interest over the life of the loan.