Compound Interest

Compound interest is a pattern of money growth in which the value of money increases at a geometric rate:

a(t) = (1 + i)^2

where a(t) refers to the value of 1 dollar (or other unit of currency) after time t, at interest rate i. For example, $1 that grows at 5% simple interest is expected to grow to $1.1025 after 2 years:

a(1) = (1.05)^2 = 1.1025.

For quantities of money larger than dollar, we can express growth as:

A_K(t) = K(1 + i)^t

Where K refers to the initial amount, or principal. For example, if we start with $5 and an interest rate of 5%, it should grow to $5.5125 after two years:

A_K(1) = 5(1.05^2) = 5.5125

Examples

Let’s repeat the above examples using the TmVal package. Let’s start by importing Amount, which is a class that can be used for compound interest calculations:

In [1]: from tmval import Amount

Let’s see how much $1 grows to after 2 years, at an interest rate of 5%:

In [2]: my_amt = Amount(k=1, gr=.05)

In [3]: print(my_amt.val(2))
1.1025

Now, let’s change the principal to $5:

In [4]: my_amt = Amount(k=5, gr=.05)

In [5]: print(my_amt.val(2))
5.5125

The output is 5.5125, the same as above.

TmVal also comes with a compound interest solver, compound_solver(), that can be used to solve for missing inputs. For example, what rate of interest would give us $5.5125, if we held $5 for two years?

In [6]: from tmval import compound_solver

In [7]: i = compound_solver(fv=5.5125, pv=5, t=2)

In [8]: print(i)
Pattern: Effective Interest
Rate: 0.050000000000000044
Unit of time: 1 year