Before coming to the question, I'll quickly explain how to calculate NPV (Net present value) with an example
Information Available
- Equipment Cost - \$20,000
- Annual Benefit - \$6,000
- Scrap Value - \$2,000
- Years in Service ($n$) - 4 Years
- Inflation Rate/Interest Rate ($r$) - 7%
What is NPV
Net Present Value is the amount of money we'll have from our investment in a particular product during the course of it's service. We calculate first the Present Value (PV) by
$$\textrm{PV} = \sum_{k=1}^{n-1}\left(\frac{\textrm{Annual Benefit}}{(1+r)^k}\right)\quad + \quad \frac{\textrm{Annual Benefit}+\textrm{Scrap Value}}{(1+r)^n}$$
that is, the present value of each annual benefit over the lifetime, plus the present value of the final year benefit.
For Final Year, we add the scrap value to annual benefit as well.
For this case the values we get are
- Y1 = \$5,607
- Y2 = \$5,240
- Y3 = \$4,897
- Y4 = \$6,103
Add them all together we get \$21,849. So at the end of 4 years we made \$21,849 on an investment of \$20000 in terms of today's money.
$$\textrm{NPV} = 21,849 - 20,000 = \textbf{\$1,849}$$
ROI
Now ROI is the value of r (Interest Rate) at which NPV comes out to be 0. At a certain value of r (for this case it's 11%), when you run the formula 4 times (for four years), the four values add up to 20,000 (the initial investment)
Can you calculate it with a formula?
PS - Can someone suggest better tags?
A tl;dr version of your question is:
Given constants $n, s, a, c$, can we find a closed form expression for $r$ that solves the equation:
$$ \sum_{i=1}^{n}\left ( \frac{a}{(1+r)^i}\right ) + \frac{s}{(1+r)^n} = c $$
Let us simplify. Let $t = \frac{1}{1 + r}$. Thus we have:
$$ \begin{align} a\sum_{i=1}^{n}t^i + st^n &= c \\ at\frac{\ 1-t^n}{1-t} + st^n &= c \\ at-at^{n+1} + st^n - st^{n+1} &= c - ct \\ at-(a+s)t^{n+1} + st^n &= c - ct \\ (a+s)t^{n+1} - st^n - (a+c)t + c &= 0 \\ \end{align} $$
Since you want to solve for $t$, you are essentially left with having to solve a polynomial of degree $n+1$. Unfortunately, if $n \geq 4$, you are completely out of luck in finding a closed form (thanks, Galois), but you could use a simple polynomial solver to quickly get solutions for $t$ and thus $r$.
Trying this out for your example in wolfram gives the solution $t = 0.90214$ which gives $x = \frac{1}{0.90214} - 1 = 0.10848$ and thus $x = 10.8$% solves the ROI for you example.
Since there might be multiple answers to polynomial, we can place bounds on valid answers. We need $0 < r < 1$ and so:
$$ \begin{align} 0 &< r < 1 \\ 1 &< 1 + r < 2 \\ \frac{1}{2} &< \frac{1}{1+r} < 1 \\ \frac{1}{2} &< t < 1 \end{align} $$
So any solution where $\frac{1}{2} < t < 1$ should be valid.