# Problem statement

The problem is to find the limit of the following sequence:

$$$$D(r) = \lim_{n \to \infty} \frac{\sum_{i=1}^{n} \frac{1}{(1+\frac{r}{n})^i}}{n}.$$$$

# Background

Consider a hypothetical example where we have an investment that costs us 50 dolars and each year generates 100 dolars for the next three years. The discount rate is 5%. Calculate the Net Present Value (NPV) of the investment.

The general formula for the NPV is:

$$$$NPV = -I + \sum_{t=1}^{T} \frac{CF_t}{(1+r)^t},$$$$ where:
$$NPV$$ is Net Present Value,
$$I$$ is Initial Investment,
$$CF_t$$ is Cash Flow at time $$t$$,
$$r$$ is discount rate,
$$T$$ is number of years.

In our case, the NPV will look like this: $$NPV = -50 + \frac{100}{(1+0.05)^1} + \frac{100}{(1+0.05)^2} + \frac{100}{(1+0.05)^3} \approx 222.325.$$

The investment is made in year zero, and the cash flow is generated at the end of the year. So, graphically, the situation looks like this:

Model 1

But this is not 100% precise. Since we invested in year 0, the cash flow started to generate right after the investment had been made. What we are doing is summing all generated cash flow for the year at the end of that year and discounting it as one piece.

Let's consider that we want to consider this. We can pick one period (year) and split it into two periods, each with half of the cash flow. The model will look like this:

Splitting into two time parts

If we want to discount the cash flow of the period to the beginning of the period, we can use the formula:

$$$$PV = \frac{\frac{CF}{2}}{(1+\frac{r}{2})} + \frac{\frac{CF}{2}}{(1+\frac{r}{2})^2}$$$$

We can also go further and split it into n periods, where n is a natural number (non zero). The model will look like this:

Splitting into n time parts

Here, the formula for discounting the cash flow of the period to the beginning of the period will look like this:

$$$$PV = \sum_{i=1}^{n} \frac{\frac{CF}{n}}{(1+\frac{r}{n})^i} = \frac{CF}{n} \sum_{i=1}^{n} \frac{1}{(1+\frac{r}{n})^i} = CF \frac{\sum_{i=1}^{n} \frac{1}{(1+\frac{r}{n})^i}}{n}.$$$$

Now, we can assign a variable to the second part of the equation and call it $$D_n(r, n)$$:

$$$$D_n(r, n) = \frac{\sum_{i=1}^{n} \frac{1}{(1+\frac{r}{n})^i}}{n}.$$$$

Therefore, we can rewrite the equation for the present value as:

$$$$PV = CF \cdot D_n(r, n).$$$$

The formula for our NPV will, therefore, look like this:

$$$$NPV = -I + CF_1 \cdot D(r) + \frac{CF_2 \cdot D(r)}{1 + r} + \frac{CF_3 \cdot D(r)}{(1 + r)^2}.$$$$

We can also rewrite the general formula for the NPV to look like this:

$$$$NPV = -I + \sum_{t=1}^{T} \frac{CF_t \cdot D(r)}{(1 + r)^{t-1}}.$$$$

If we want the continuous discounted cash flow generation, we can use the limit of the $$D_n(r, n)$$ as $$n$$ goes to infinity. The equation will look like this:

$$$$D(r) = \lim_{n \to \infty} D_n(r, n) = \lim_{n \to \infty} \frac{\sum_{i=1}^{n} \frac{1}{(1+\frac{r}{n})^i}}{n}.$$$$

So the problem is to find this limit:

$$$$D(r) = \lim_{n \to \infty} \frac{\sum_{i=1}^{n} \frac{1}{(1+\frac{r}{n})^i}}{n}.$$$$

# My attempts

I tried to check the behaiour in Wolfram Mathematica using this code:

(* Wolfram Mathematica 14.0 *)

ClearAll["Global*"]

(* General formula for NPV *)
NPV1[I_, CFlist_, r_] := -I +
TimeValue[Cashflow[CFlist, 1], r, 0]/(1 + r);

(* Formula for D_n(r, n) *)
DD[r_, n_] := Sum[1/(1 + r/n)^i, {i, 1, n}]/n;

(* Updated formula for NPV with D_n(r, n) *)
NPV2[I_, CFlist_, r_, n_] := -I +
TimeValue[Cashflow[CFlist, 1], r, 0]*DD[r, n];

r = 0.05;
nMax = 20;

lp1 = ListPlot[
{
Table[NPV1[50, {100, 100, 100}, r], {n, 1, nMax}],
Table[NPV2[50, {100, 100, 100}, r, n], {n, 1, nMax}]
},
PlotRange -> All,
PlotStyle -> PointSize[Medium],
AxesLabel -> {"n", "NPV (\$)"},
PlotLegends -> {"NPV1", "NPV2"}
]

lp2 = ListPlot[
{
Table[DD[r, n], {n, 1, nMax}],
Table[1/Exp[r], {n, 1, nMax}]
},
PlotRange -> All,
PlotStyle -> PointSize[Medium],
AxesLabel -> {"n"}
]

SetDirectory[NotebookDirectory[]];

Export["img/lp1.png", lp1];
Export["img/lp2.png", lp2];
`

The results are in the following figures:

NPV comparison

Approximations $$D_n(r, n)$$

The value of $$D_n(r, n)$$ seems to converge as $$n$$ goes to infinity, but not to $$1 / e^r$$, as could be expected as it is used for continuous discounting.

I think you are mixing some concepts. Your formula does not approximate the continously compounded interest. The correct formula is

$$FV = \lim_{n \to \infty} I \bigg(1+\frac{r}{n}\bigg)^n = Ie^r$$

(for the NPV just invert this formula). The idea behind this is that you invest the sum $$I$$ for $$n$$ periods (each year per $$t$$ years - note that here we also assuming $$t=1$$). this means we have something like this $$I \bigg(1+\frac{r}{n}\bigg)\cdots \bigg(1+\frac{r}{n}\bigg)$$ where we have $$n$$ of those terms. If we then let the number of compounding periods tend to infinity we have the classical approximation of continously compounded interest.

Your $$D(r)$$ is not equivalent. We can however compute the limit by remembering that

$$S := \sum_{i=1}^{n}z^i = \frac{z-z^{n+1}}{1-z} = \frac{z(1-z^{n})}{1-z}$$ where in our case $$z = 1/(1+r/n)$$.

Hence, after some algebra, we end up with

$$D(r) = \frac{S}{n} = \frac{1}{r}\bigg[1 - \bigg( \frac{1}{1+r/n}\bigg)^n \bigg] \to \frac{1}{r} (1-e^{-r})$$ when $$n \to \infty$$. If you plug in $$r=5\%$$ as in you example we get $$D(5\%) \approx 0.975411$$ which resambles your code.