Estimate the discount rate at which the net present value (NPV) of all cash flows equals zero.
—
Enter cash flows to see the IRR
Understanding the Internal Rate of Return (IRR)
The Internal Rate of Return (IRR) is a fundamental metric used in capital budgeting and financial analysis to estimate the profitability of potential investments. It represents the annualized effective compounded rate of return that a project or investment is expected to yield. More technically, IRR is the discount rate at which the Net Present Value (NPV) of all the cash flows (both positive and negative) from a particular project or investment equals zero.
How IRR is Calculated
The IRR is found by solving the following equation for 'r' (the IRR):
NPV = Σ [CFt / (1 + r)t] = 0
Where:
CFt is the cash flow during period t.
r is the IRR (the discount rate we are trying to find).
t is the time period (e.g., year 0, year 1, year 2…).
Σ represents the sum of all cash flows.
The initial investment is typically a negative cash flow at time t=0. The equation is a polynomial, and for more than a few periods, it often cannot be solved algebraically. Therefore, financial software like Excel, or specialized calculators like this one, use iterative numerical methods (like the Newton-Raphson method) to approximate the IRR.
How to Use This Calculator
Enter Cash Flows: In the input field, list your project's expected cash flows, separated by commas. The first number should usually be your initial investment (a negative value). Subsequent numbers represent the expected cash inflows or outflows for each period (typically years).
Calculate: Click the "Calculate IRR" button.
Interpret Result: The calculator will display the IRR as a percentage.
Interpreting the IRR
Decision Rule: Generally, a project is considered acceptable if its IRR is greater than the company's required rate of return (also known as the hurdle rate or cost of capital). If IRR > Hurdle Rate, the project is likely to add value. If IRR < Hurdle Rate, it may destroy value.
Comparison: IRR is often used to compare mutually exclusive projects. The project with the higher IRR is typically preferred, assuming both are acceptable based on the hurdle rate.
Important Considerations & Limitations
Multiple IRRs: Projects with non-conventional cash flows (where the sign of the cash flow changes more than once, e.g., negative, positive, negative, positive) can have multiple IRRs, making interpretation difficult.
No IRR: Some cash flow patterns might result in no real IRR.
Reinvestment Assumption: IRR implicitly assumes that all positive cash flows generated by the project are reinvested at the IRR itself. This may not be realistic, especially for high IRR projects. The Modified Internal Rate of Return (MIRR) addresses this limitation.
Scale of Projects: IRR doesn't consider the scale of the investment. A project with a high IRR but small initial investment might be less desirable than a project with a slightly lower IRR but a much larger initial investment and total dollar return. NPV is often preferred for comparing projects of different scales.
Example Usage
Consider an investment with the following cash flows:
Year 0: -$10,000 (Initial Investment)
Year 1: $3,000 (Cash Inflow)
Year 2: $4,000 (Cash Inflow)
Year 3: $5,000 (Cash Inflow)
Entering -10000, 3000, 4000, 5000 into the calculator yields an IRR of approximately 14.16%.
If your company's required rate of return (hurdle rate) is 10%, this project would likely be accepted because its IRR (14.16%) is higher than the hurdle rate.
function calculateIRR() {
var cashFlowsInput = document.getElementById("cashFlows").value;
var resultDiv = document.getElementById("result");
if (!cashFlowsInput) {
resultDiv.innerHTML = "Error: Please enter cash flows.";
resultDiv.style.backgroundColor = "#dc3545"; // Red for error
return;
}
var cashFlows = cashFlowsInput.split(',')
.map(function(item) {
var trimmed = item.trim();
if (isNaN(parseFloat(trimmed))) {
throw new Error("Invalid number format in cash flows.");
}
return parseFloat(trimmed);
});
if (cashFlows.length === 0) {
resultDiv.innerHTML = "Error: No valid cash flows entered.";
resultDiv.style.backgroundColor = "#dc3545";
return;
}
// Basic check for at least one negative and one positive cash flow if multiple exist
var positiveFlows = cashFlows.filter(function(cf){ return cf > 0; }).length;
var negativeFlows = cashFlows.filter(function(cf){ return cf 1 && (positiveFlows === 0 || negativeFlows === 0)) {
resultDiv.innerHTML = "Warning: IRR requires both positive and negative cash flows for a meaningful result.";
resultDiv.style.backgroundColor = "#ffc107"; // Warning yellow
// Proceeding anyway, but warning the user
}
// Check if the first cash flow is not negative (initial investment)
if (cashFlows[0] >= 0 && cashFlows.length > 1) {
resultDiv.innerHTML = "Warning: Initial cash flow (first entry) should typically be negative (an investment).";
resultDiv.style.backgroundColor = "#ffc107"; // Warning yellow
}
try {
var irr = irr_newton_raphson(cashFlows);
if (isNaN(irr) || irr === null) {
resultDiv.innerHTML = "Could not calculate IRR. Check cash flows.";
resultDiv.style.backgroundColor = "#dc3545";
} else {
resultDiv.innerHTML = (irr * 100).toFixed(2) + "%" + "Internal Rate of Return";
resultDiv.style.backgroundColor = "var(–success-green)"; // Reset to success green
}
} catch (e) {
resultDiv.innerHTML = "Error: " + e.message;
resultDiv.style.backgroundColor = "#dc3545";
}
}
// Helper function to calculate NPV for a given rate
function calculateNPV(rate, cashFlows) {
var npv = 0.0;
for (var i = 0; i < cashFlows.length; i++) {
npv += cashFlows[i] / Math.pow(1 + rate, i);
}
return npv;
}
// Newton-Raphson method for IRR calculation
function irr_newton_raphson(cashFlows, guess, tolerance, maxIterations) {
guess = guess === undefined ? 0.1 : guess; // Initial guess for IRR
tolerance = tolerance === undefined ? 1e-6 : tolerance; // Desired precision
maxIterations = maxIterations === undefined ? 1000 : maxIterations; // Safety break
var rate = guess;
var npv, deriv_npv;
for (var i = 0; i < maxIterations; i++) {
npv = calculateNPV(rate, cashFlows);
// Calculate derivative of NPV with respect to rate
deriv_npv = 0;
for (var t = 1; t < cashFlows.length; t++) {
deriv_npv -= t * cashFlows[t] / Math.pow(1 + rate, t + 1);
}
// Avoid division by zero or very small numbers
if (Math.abs(deriv_npv) < 1e-10) {
// If derivative is near zero, we might be at a flat spot or minimum/maximum.
// Try a small perturbation or return current estimate if NPV is close enough.
if (Math.abs(npv) < tolerance) return rate;
rate += tolerance; // Small adjustment
continue;
}
var new_rate = rate – npv / deriv_npv;
if (Math.abs(new_rate – rate) < tolerance) {
// Check if the calculated NPV at the new rate is indeed close to zero
if (Math.abs(calculateNPV(new_rate, cashFlows)) 100.0 || rate 10000% or < -100%)
// console.warn("IRR calculation approaching unrealistic rate, trying a different guess or method might be needed.");
}
}
// If max iterations reached without convergence, return the last calculated rate
// Or indicate failure if NPV is still far from zero
if (Math.abs(calculateNPV(rate, cashFlows)) < tolerance * 10) { // Allow slightly wider tolerance if max iterations hit
return rate;
}
return NaN; // Indicate failure to converge
}