Enter the initial cost as a positive number. The calculator treats this as a cash outflow.
Enter the net cash flow for each period (year or month), separated by commas or new lines.
function calculateIRR() {
var initialInvInput = document.getElementById('initialInvestment').value;
var cashFlowsInput = document.getElementById('cashFlows').value;
var resultDiv = document.getElementById('irrResult');
// Reset display
resultDiv.style.display = 'none';
resultDiv.innerHTML = ";
// Validation
if (!initialInvInput || isNaN(parseFloat(initialInvInput))) {
resultDiv.style.display = 'block';
resultDiv.innerHTML = 'Please enter a valid Initial Investment amount.';
return;
}
if (!cashFlowsInput.trim()) {
resultDiv.style.display = 'block';
resultDiv.innerHTML = 'Please enter at least one subsequent cash flow.';
return;
}
// Parse Inputs
var c0 = parseFloat(initialInvInput) * -1; // Investment is outflow (negative)
// Clean and parse cash flows
var flowString = cashFlowsInput.replace(/\n/g, ",");
var flowArrayRaw = flowString.split(",");
var flows = [];
for (var i = 0; i 0 && npvMax > 0) {
resultDiv.style.display = 'block';
resultDiv.innerHTML = 'IRR is extremely high (>1000%) or does not exist.';
return;
}
if (npvMin < 0 && npvMax < 0) {
resultDiv.style.display = 'block';
resultDiv.innerHTML = 'IRR is extremely low (<-100%) or investment never breaks even.';
return;
}
while (iteration < maxIterations) {
guess = (minRate + maxRate) / 2;
npv = calculateNPV(guess, allFlows);
if (Math.abs(npv) 0) {
// Rate is too low (since NPV decreases as Rate increases usually)
minRate = guess;
} else {
// Rate is too high
maxRate = guess;
}
iteration++;
}
resultDiv.style.display = 'block';
if (found || Math.abs(maxRate – minRate) < 0.0001) {
var percentage = (guess * 100).toFixed(2);
resultDiv.innerHTML = '
Internal Rate of Return
' + percentage + '%
';
} else {
resultDiv.innerHTML = 'Could not converge on a solution. Please check your cash flows.';
}
}
function calculateNPV(rate, flows) {
var npv = 0;
for (var t = 0; t < flows.length; t++) {
npv += flows[t] / Math.pow(1 + rate, t);
}
return npv;
}
Understanding Internal Rate of Return (IRR)
The Internal Rate of Return (IRR) is a critical financial metric used to evaluate the profitability of potential investments. It represents the annual rate of growth that an investment is expected to generate. In technical terms, IRR is the discount rate that makes the Net Present Value (NPV) of all cash flows (both positive and negative) from a specific project equal to zero.
Investors and businesses use IRR to compare different investment opportunities. Generally, the higher the IRR, the more desirable the investment.
The Calculation Logic
Calculating IRR requires solving for the rate ($r$) in the following equation:
Because the variable $r$ is in the denominator with varying exponents, there is no simple linear algebraic formula to solve for it directly. Instead, calculators like the one above use iterative numerical methods (such as the Bisection Method or Newton-Raphson) to approximate the value.
Example Scenario
Let's look at a practical example. Imagine you are considering purchasing a piece of machinery for your business.
Initial Cost: $10,000
Year 1 Return: $3,000
Year 2 Return: $4,000
Year 3 Return: $5,000
Using the calculator above:
Enter 10000 in the Initial Investment field.
Enter 3000, 4000, 5000 in the Subsequent Cash Flows field.
The calculator will determine the rate at which these future cash flows, discounted back to today, equal exactly $10,000. In this case, the IRR is approximately 8.9%.
IRR vs. ROI
While both metrics measure performance, they differ significantly:
Metric
Description
Best Used For
IRR
Annualized percentage rate taking the time value of money into account.
Long-term projects with varying cash flows over time.
ROI
Total percentage return ((Net Profit / Cost) * 100). Ignores the timing of cash flows.
Simple, short-term investments or quick comparisons.
What is a "Good" IRR?
A "good" IRR is relative to the Cost of Capital or the Hurdle Rate of the company or investor. If the calculated IRR is higher than the cost of borrowing money or the expected return from a safe investment (like government bonds), the project is typically considered viable.
For example, if a company has a hurdle rate of 10%, a project with an IRR of 15% is attractive, while a project with an IRR of 8% would likely be rejected.
Limitations
Multiple Solutions: If cash flows alternate between positive and negative more than once (e.g., a project requires a mid-term cash injection), mathematically there can be multiple IRR values.
Scale Ignorance: IRR gives a percentage, not a dollar amount. A 50% IRR on a $1 investment ($0.50 profit) is mathematically better than a 10% IRR on a $1,000,000 investment ($100,000 profit), but the latter creates more wealth.
Frequently Asked Questions
Can IRR be negative?
Yes. If the sum of your cash flows is less than your initial investment, your IRR will be negative, indicating a loss.
Does this calculator handle monthly cash flows?
Yes, but the result will be the periodic IRR. If you enter monthly cash flows, the result is the Monthly IRR. To get the Annualized IRR, you would calculate $(1 + \text{MonthlyIRR})^{12} – 1$.