### 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, , of a present value, , in -periods from now at a fixed interest rate per period, , 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 is the annual interest rate, 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, , a monthly deposit, , an annual interest rate , what is the compound future value in months from now if interest is paid monthly?

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

where equals . 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

In general the balance at month equals

To calculate we would need to calculate first which in turn requires a calculation of . This processes continues all the way down to 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 else return kn_rec(p-1) * (1 + $i_rel) + $m end end 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 .

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

By multiplying out we arrive at

where we could write the last addend as

which we can rewrite using the summation-symbol as

To generalize for 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).

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

which we will happily apply to our summation in

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.

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