On Compound Interest – Closed-Form Solutions

Introduction and Monthly Compounding

Wikipedia describes compound interest as

Compound interest arises when interest is added to the principal, so that from that moment on, the interest that has been added also itself earns interest.

In its most simple form the compound future value, FV, of a present value, PV, in N-periods from now at a fixed interest rate per period, i, is given by


This formula works well for a fixed amount of money, but does not qualify for monthly deposits. What is the formula that includes monthly deposits then? I wondered about the answer to this question a day ago and since I did not have a solution hands, I thought to give it a try and develop one ‘myself’ using the equation above as a starting point.

Warning The formulas presented in this post are probably incomplete and mostly untested. Use at your own risk.

Without loss of generality we will assume monthly compounding. That is, interest is being paid each month. This is actually quite uncommon for a savings account around the area I live at, but it makes the formulae a little bit easier to read. Typically the interest rate is presented as an per-year interest rate. To account for monthly compounding we need to change the formula above to


where i is the annual interest rate, N is the number of months.

We will make the following assumptions

  • The annual interest rate remains fixed during all periods and is paid each month.
  • The amount of monthly deposit is the same for all periods.
  • Inflation and taxes are not existing.

Under the given assumptions the detailed question to be answered reads as follows: given an initial balance, K_0, a monthly deposit, M, an annual interest rate i, what is the compound future value in N months from now if interest is paid monthly?

First, we observe that the future value at end of the first month is equal to

K_1 = K_0*(1 + i_{rel}) + M

where i_{rel} equals \frac{i}{12}. To say it out loud, at the end of the first month our balance will consist of our initial balance plus its paid interest plus the first monthly deposit (for which interest will be paid the first time at the end of month two). Similarly we observe that the balance of at the end of month two involves whatever the balance was in month one

K_2 = K_1*(1 + i_{rel}) + M

In general the balance at month N equals

K_N = K_{N-1}*(1 + i_{rel}) + M

To calculate K_N we would need to calculate K_{N-1} first which in turn requires a calculation of K_{N-2}. This processes continues all the way down to K_0 of which the value is known. The family of function definitions that contain an application of the function being defined are called recursive function definitions. Recursion is highly welcomed concept in computer programming as it can be applied to solve variety of problems.

In Ruby, for example, the recursive formulation reads

# input
$k0 = 2000.0       # initial balance
$m = 500.0         # monthly deposit
$i = 0.05          # interest rate
$i_rel = $i / 12   # relativ interest rate
$n = 36            # number of periods

# monthly compounded, recursive
def kn_rec(p)
  if p == 0
    return $k0
    return kn_rec(p-1) * (1 + $i_rel) + $m
fv = kn_rec(36)
puts "Future value equals #{fv}"  #=> 21699.61

Recursion is powerful in computer science, but evaluating it by hands using your calculator quickly gets tedious and boring. After all, you would need to evaluate the formula 36 times in the above example. Not something you would like to do if you need your answer quickly. Besides performance another negative side effect of recursion is increased memory consumption, since all evaluations that need to be kept in memory.

To improve we should try to find a closed-form expression of the above recursive formulation. In other words: a formulation that consists of a fixed amount of multiplications and additions independent of N.

We start by observing what happens symbolically if we expand K_1 in the equation for K_2 and further expand K_2 in the equation for K_3.

K_2 = (K_0*(1 + i_{rel}) + M)*(1 + i_{rel}) + M
K_3 = ((K_0*(1 + i_{rel}) + M)*(1 + i_{rel}) + M)*(1 + i_{rel}) + M

By multiplying out we arrive at

K_2 = K_0*(1 + i_{rel})^2 + M*(1 + i_{rel})^1 + M
K_3 = K_0*(1 + i_{rel})^3 + M*(1 + i_{rel})^2 + M*(1 + i_{rel})^1 + M

where we could write the last addend as M=M*(1+i_{rel})^0

K_2 = K_0*(1 + i_{rel})^2 + M*(1 + i_{rel})^1 + M*(1+i_{rel})^0
K_3 = K_0*(1 + i_{rel})^3 + M*(1 + i_{rel})^2 + M*(1 + i_{rel})^1 + M*(1+i_{rel})^0

which we can rewrite using the summation-symbol as

K_2 = K_0*(1 + i_{rel})^2 + M*\sum_{n=0}^{1}(1 + i_{rel})^n
K_3 = K_0*(1 + i_{rel})^3 + M*\sum_{n=0}^{2}(1 + i_{rel})^n

To generalize for K_N we simply turn the pattern that emerged into a new formula (hopefully this is not one of the cases where humans see patterns in random series, as Kahnemann often noted).

K_N = K_0*(1 + i_{rel})^N + M*\sum_{n=0}^{N-1}(1 + i_{rel})^n

Are we doing any better now? No, since we still need to tediously evaluate the sum at very right hand side. Fortunately, the series has a constant ratio of successive terms which makes it a geometric series. For geometric series a closed form summation is given by

\sum_{i=0}^{N}q^i = \frac{q^{N+1} - 1}{q-1}

which we will happily apply to our summation in K_N

K_N = K_0*(1 + i_{rel})^N + M*\frac{(1 + i_{rel})^N - 1}{(1 + i_{rel}) - 1}

Finally we arrived at a closed-form solution that can be easily evaluated using just a piece of paper and a calculator. Just in case you wonder, a straight forward application in Ruby is

# ... using the same globals as in the above snippet

# monthly compounded, closed-form
geo_series = (((1 + $i_rel)**$n - 1)/((1 + $i_rel) - 1))
fv = $k0 * (1 + $i_rel)**$n + $m * geo_series
puts "Future value equals #{fv}" #=> 21699.61

I think it is safe to say that the closed-form application should be preferred to the iterative/recursive one whenever possible. Not only does it take fewer instructions but also offers an improved memory footprint.


One thought on “On Compound Interest – Closed-Form Solutions

  1. Pingback: On Compound Interest – Closed-Form Solutions II « Christoph Heindl

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s