# Derivation of the loan/mortgage monthly payment formula

I like to know where my formulas come from. I’m currently looking into purchasing a new vehicle, and with that will possibly be a car loan. Coming from an math/engineer perspective, I’ve found the specifics of car loans to be lacking. But that isn’t necessarily the point of this post. Many times, you want to know, given the size of the loan, the “interest rate”, and the number payments, how big will the monthly payment be?

So let’s derive it ourselves.

First, let’s define some variables. Let

Initial loan size ($)

Interest rate described as an annual number (%, 0-1)

Interest rate per month (%, 0-1)

Monthly payment ($)

Number of payments (months)

The way these loans typically work is that every month you have an interest payment on the amount you owe on the loan (principal). Anything extra that you pay that isn’t part of the interest payment will deduct from your total principal.

So let’s start from month 1. The amount of interest you owe will be the initial loan size, multiplied by the interest rate.

What should that interest rate be though? It’s usually not specified clearly in many places, but it’s often assumed that it’s the annual rate divided by 12 months, which we are denoting as .

For this first payment the amount you are going to reduce the principal by is

So the principal after the first payment, will be

With a little algebra, this is equivalent to

From here, you can just continue the pattern, and it should be apparent that the following recursive formula is true.

This equation is the basis for all the loan payment formulas. But at this point, it’s not very useful.

We need to get rid of this subscript stuff. So let’s just start looking at bigger values of beyond 1, substituting for variables until we have only variables that we know. Let’s look at the case and see if we can spot some patterns. Using Eq. \eqref{eq:recursive},

Substituting Eq. \eqref{eq:n2} into \eqref{eq:n3}

Rearranging,

Let do one more substitution, Eq. \eqref{eq:n1} into \eqref{eq:newP3}.

Distribute that ,

or

Cool. So we got to a point where we only have a and other terms we know ( and ). The problem is that as we keep going, we add one more term and that gets messy. Is there a way to simplify that?

If you were paying attention in calculus class, you may recognize that
type of series the terms are going through. It’s known by math
people as a *geometric series*, one in which you are multiplying by a
factor over and over again. In our case, that factor is .

A finite geometric series is defined by the form

(We typically stop at because we usually want to equal the total number of terms, and we have to include that .)

This has a well known formula for the sum (for a derivation, check out Khan Academy).

Almost there. Now we can replace the terms in the square brackets in Eq. \eqref{eq:rearrangedform} with our formula for the sum where for us is like and is like .

We are interested in when as this means the principal has gone to 0 and you owe nothing more! After all this work, one version of our final form is

We now have an equation, with four variables. Given 3 of them, we can use algebra to find the 4th. Now normally, you aren’t solving for , the loan amount, but nothing would stop you. The equation most people will be interested in is solving Eq. \eqref{eq:base} for , the monthly payment. With algebra, that formula is

The equation for , the number of payment months, is less well known, but we can still get it.

Algebra time. Solving for …

Phew. I played around with trying to find a closed form solution for , but this proved to be much more of a challenge. Simplified it a bit with some binomial coefficient formulas, but no luck completely isolating . Since you have , you get lots of solutions. Best way is to just numerically solve it using traditional techniques.