Rate of Return:

This JavaScript program calculates the Internal Rate of Return (IRR) for a Net Present Value (NPV). You have two methods to calculate the IRR: Find the Root and Use Grid Search. If one method does not work, then try the other.

This program is powerful. You can also change the Years and both methods update the calculation of the Net Present Value.

Using the Program:

At least one year has to be negative. A negative number indicates an outflow, while a positive number represents an inflow. If you leave a cell blank, then a zero is entered into the calculation for that year.

You cannot add commas or dollars signs into the fields. The program does not understand them. However, you can add arithmetic operations to any of the cells. The program interprets the arithmetic operations:

  • Addition is +
  • Subtraction is -
  • Multiplication is *
  • Division is /
  • For example, if you entered 1000-10*10 into Year 7 results in 900 for that cell.

The Accuracy is how close the Net President Value is to the IRR axis. If the IRR is 1 cent or lower, then the program found the correct IRR. The Iterations is how many times the program tried to find the correct IRR.

Find the Root

The program starts with two starting values and then calculates a slope that points in the direction where the Net Present Value crosses the IRR axis. Then the program iteratively approaches the crossing point. For standard values, this program is accurate and a solution can be found within 10 iterations.

Use Grid Search

This program uses a grid search to find the rate of return between 0 and 100%. This program starts calcuating 10 values between 0 and 100%. Once it finds the IRR that is closest to the axis, then the program hones in around that number with another 10 values for the next decimal place. Then it iteratively hones in on the root.

The Grid Search is very accurate, if the Internal Rate of Return is between 0 and 100%.

 

FOLLOW ME