- Definition
- Takeaway
- Formula
- Example
- Python Code
- Simple TVM Equation
- TVM Equation with periods. Compounding.
- TVM with Periods Per Year
- TVM Visualization

**This is not investment advice, there is no implication of any guarantee. All investment is risky and you should take advice from actual advisors. EDUCATION ONLY.**

## Definition

The value of an asset or money change over time. One dollar today is not the same as 20 years from now. If you don’t invest your money, you will generally be actively losing it. We need a calculation which allows us to compute what our money will be worth in the future.

## Takeaway

Compounding is an important model to know. Elements do not always grow at a constant rate. Sometimes they grow based on their state during each period of growth. They compound.

Rather than a linear fashion, we need to explore simple concepts to illustrate the idea, then show the effects of compounding.

Using Python we will show the model’s evolution and then visualize its growth pattern using some simple plotting.

## Formula

- FV = Future value of money
- PV = Present value of money
- i = interest rate
- n = number of compounding periods per year
- t = number of years

### Example

Let us assume we have $100. Our money will grow by 3% annually. We want to know how much money we will have each year, for seven years.

## Python Code

I was really surprised when doing online research. This is typically either omitted or displayed in a complex way. Let’s start simple, one period of time.

### Simple TVM Equation

```
def simple_tvm(PV,i):
FutureValue = (PV * i) + PV
print(FutureValue)
simple_tvm(100,.03)
```

103.0

### TVM Equation with periods. Compounding.

Next, we add in the equation for periods.

```
def periods_tvm(PV,i,t):
for periods in range(t):
FutureValue = (PV * i) + PV
print(FutureValue)
PV = FutureValue
periods_tvm(100,.03, 7)
```

103.0 106.09 109.2727 112.550881 115.92740743 119.4052296529 122.987386542487

### TVM with Periods Per Year

Then we finish the full equation with multiple periods occurring each year.

```
def periods_tvm(PV,i,t,n):
t = t*n
i = i/n
for periods in range(t):
FutureValue = (PV * i) + PV
print(FutureValue)
PV = FutureValue
periods_tvm(100,.03, 7,4)
```

100.75 101.505625 102.2669171875 103.03391906640626 103.80667345940431 104.58522351034983

...

### TVM Visualization

```
plot_list = []
def periods_tvm(PV,i,t):
for periods in range(t):
FutureValue = (PV * i) + PV
PV = FutureValue
plot_list.append(FutureValue)
periods_tvm(100,.03, 300)
import matplotlib.pyplot as plt
plt.plot(plot_list)
plt.ylabel('Compounding Interest')
plt.show()
```