# Convergence Example / IRR calculation

## Convergence and Recursion Example for Internal Rate of Return

You buy a
mountain cabin for $25,000. During the first four years you are able to rent it
out and you collect $3,500, $100, $4000 and $100 respectively. The fifth year
you have a negative cash flow of $300 due to repairs. The cash flows for years 6
through 11 are : 4000, 2300, -150, 5600, 321, and -100. In the twelfth year you
sell the cabin for $24,900. You ask yourself, would you have been better off
depositing your $25,000 at 6% or is the series of cash flows generated by your
investment greater in value? In our example, the interest rate that would
generate a $25,000 NPV to match the initial investment is 6.847%. This interest
rate is called the Internal Rate of Return (IRR) and it cannot be computed
analytically. There are instances when several solutions are possible and
sometimes there are no solutions.
The program should look only for solutions that are financially acceptable
(e.g. between 0% and 200%) and it should return the lowest if more than one are
available. The irr function should look for a solution by moving on the graph
from 0% to the right in assigned increments while trying to match the initial
investment with the NPV generated by the current interest rate. If the
difference between Investment and NPV changes signs, then the function has moved
too far and it should step back to the prior tick and continue with smaller
increments. This process should invoke itself recursively until the difference
is smaller then a ten thousandth of the NPV.

## The values in the form are from the sample above. Feel free to change
them