Mortgage Payments

 

We want to understand the relationships between the mortgage payment rate 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 (as is usually the case in the U. S.) that payments are made monthly, even though the interest rate is given as an annual rate.  Let's define

 

peryear = 1/12; percent = 1/100;

 

So the number of payments on a thirty-year loan is

 

30*12

 

ans =

   360  

 

and an annual percentage rate of 8% comes out to a monthly rate of

 

8*percent*peryear

 

ans =

    0.0067  

 

Now consider what happens with each monthly payment.  Some of the payment is applied to interest on the outstanding principal amount, P, and some of the payment is applied to reduce the principal owed.  The total amount, R, of the monthly payment, remains constant over the life of the loan.  So if J denotes the monthly interest rate, we have R = J*P + (amount applied to principal), and the new principal after the payment is applied is

P + J*P -  R = P*(1 + J)  -  R  = P*m  -  R ,

where m = 1 + J.  So a table of the amount of the principal still outstanding after n payments is tabulated as follows for a loan of initial amount A, for n from 0 to 6:

 

syms m J P R A n

P = A;

for n = 0:6,

    disp([n, P]),

    P = simplify(-R + P*m);

end

 

[ 0, A]

[      1, -R+A*m]

[            2, -R-m*R+A*m^2]

[                  3, -R-m*R-m^2*R+A*m^3]

[                        4, -R-m*R-m^2*R-m^3*R+A*m^4]

[                              5, -R-m*R-m^2*R-m^3*R-m^4*R+A*m^5]

[                                    6, -R-m*R-m^2*R-m^3*R-m^4*R-m^5*R+A*m^6]  

 

 

We can write this in a simpler way by noticing that P = A*mn + (terms divisible by R).  For example, with n = 7 we have:

 

factor(P - A*m^7)

 

ans =

-R*(1+m+m^2+m^3+m^4+m^5+m^6)  

 

But on the other hand the quantity inside the parentheses is the sum of a geometric series

.

 

So we see that the principal after n payments can be written as  

P = A*mn - R*(mn- 1) / (m - 1).

Now we can solve for the monthly payment amount R under the assumption that the loan is paid off in N installments, i.e., P is reduced to 0 after N payments:

 

syms N; solve(A*m^N - R*(m^N - 1)/(m - 1), R)

 

ans =

A*m^N*(m-1)/(m^N-1)  

 

R = subs(ans, m, J + 1)

 

R =

A*(J+1)^N*J/((J+1)^N-1)  

 

For example, with an initial loan amount A = $150,000 and a loan lifetime of 30 years (360 payments), we get the following table of payment amounts as a function of annual interest rate:

 

syms n; format bank;

for rate = 1:10,

disp([rate,double(subs(R,[A,N,J],[150000,360,rate*percent*peryear]))]),

end   

 

          1.00        482.46

          2.00        554.43

          3.00        632.41

          4.00        716.12

          5.00        805.23

          6.00        899.33

          7.00        997.95

          8.00       1100.65

          9.00       1206.93

         10.00       1316.36  

 

Note the use of format bank to write the floating-point numbers with two digits after the decimal point, and of syms to reset n to an undefined symbolic quantity.

 

There's another way to understand these calculations that's a little slicker, and that uses MATLAB's linear algebra capability.  Namely, we can write the fundamental equation

Pnew = Pold*m  -  R

in matrix form as

vnew = B vold

where v is the column vector   and B is the square matrix

.

We can check this using matrix multiplication:

 

syms R P; B = [m -R; 0 1]; v = [P; 1]; B*v  

 

ans =

[ m*P-R]

[     1]  

 

which agrees with the formula we had above.  Thus the column vector [P; 1] resulting after n payments can be computed by left multiplying the starting vector [A; 1] by the matrix Bn.   Assuming m > 1, that is, a positive rate of interest, the calculation

 

[eigenvectors, diagonalform] = eig(B)  

 

eigenvectors =

[       1,       1]

[       0, (m-1)/R]

diagonalform =

[ m, 0]

[ 0, 1]  

 

shows us that the matrix B has eigenvalues m, 1, and corresponding eigenvectors [1; 0] and [1; (m -1)/R] = [1; J / R].  Now we can write the vector [A; 1] as a linear combination of the eigenvectors: [A; 1]  = x[1; 0] + y [1; J / R].  We can solve for the coefficients:

 

[x, y] = solve('A = x*1 + y*1', '1 = x*0 + y*J/R')  

 

x =

(A*J-R)/J

y =

R/J  

 

and so

[A; 1] = (A - (R / J))*[1; 0] + (R / J)*[1; J] 

and 

Bn× [A; 1] = (A - (R / J))*mn*[1; 0] + (R / J)*[1; J]. 

 

So the principal remaining after n payments is:

P = ((A* J - R )*mn + R ) / J = A*mn - R *(mn - 1) / J.  

This is the same result we obtained earlier.

 

To conclude, let's determine the amount of money A one can afford to borrow as a function of what one can afford to pay as the monthly payment R.  We simply solve for A in the equation that P = 0 after N payments.

 

solve(A*m^N - R*(m^N - 1)/(m - 1), A)  

 

ans =

R*(m^N-1)/(m^N)/(m-1)  

 

 

For example, if one is shopping for a house and can afford to pay $1500 per month for a 30-year fixed-rate mortgage, the maximal loan amount as a function of the interest rate is given by:

 

for rate = 1:10,

disp([rate,double(subs(ans,[R,N,m],[1500,360,1+rate*percent*peryear]))]),end

 

          1.00     466360.60

          2.00     405822.77

          3.00     355784.07

          4.00     314191.86

          5.00     279422.43

          6.00     250187.42

          7.00     225461.35

          8.00     204425.24

          9.00     186422.80

         10.00     170926.23