Internal Rate of Return Calculator Online

Internal Rate of Return (IRR) Calculator

The Internal Rate of Return (IRR) is a crucial metric used in capital budgeting to estimate the profitability of potential investments. It represents the discount rate at which the net present value (NPV) of all cash flows (both positive and negative) from a particular investment equals zero. In simpler terms, it's the effective compounded annual rate of return that an investment is expected to yield.

A higher IRR indicates a more desirable investment. Businesses often use IRR to compare different investment opportunities. If the IRR of a project is higher than the company's required rate of return (also known as the hurdle rate or cost of capital), the project is generally considered acceptable. However, it's important to note that IRR can sometimes be misleading, especially with unconventional cash flow patterns or when comparing mutually exclusive projects of different scales.

Investment Cash Flows

Enter the initial investment (as a negative value) and subsequent cash flows for each period. For example, an initial investment of $10,000 would be entered as -10000. Subsequent annual cash inflows would be entered as positive values.





Results

function calculateIRR() { var cashFlowsInput = document.getElementById("cashFlows").value; var guessRateInput = parseFloat(document.getElementById("guessRate").value); var resultDiv = document.getElementById("irrResult"); if (!cashFlowsInput) { resultDiv.innerHTML = "Please enter cash flows."; return; } var cashFlowsArray = cashFlowsInput.split(',').map(function(item) { return parseFloat(item.trim()); }); if (cashFlowsArray.some(isNaN)) { resultDiv.innerHTML = "Invalid cash flow format. Please ensure all entries are numbers."; return; } if (cashFlowsArray.length < 2) { resultDiv.innerHTML = "At least an initial investment and one subsequent cash flow are required."; return; } if (isNaN(guessRateInput) || guessRateInput <= 0) { resultDiv.innerHTML = "Please enter a valid positive initial guess rate."; return; } // Convert guess rate from percentage to decimal var guessRate = guessRateInput / 100; // — IRR Calculation Logic (Newton-Raphson Method) — var irr = irrNewtonRaphson(cashFlowsArray, guessRate); if (isNaN(irr)) { resultDiv.innerHTML = "Could not converge to a solution. Try a different initial guess rate or ensure cash flows are valid."; } else { var formattedIRR = (irr * 100).toFixed(2); resultDiv.innerHTML = "The estimated Internal Rate of Return (IRR) is: " + formattedIRR + "%"; } } // Helper function to calculate NPV for a given rate function calculateNPV(rate, cashFlows) { var npv = 0; for (var i = 0; i < cashFlows.length; i++) { npv += cashFlows[i] / Math.pow(1 + rate, i); } return npv; } // Helper function to calculate the derivative of NPV with respect to rate function derivativeNPV(rate, cashFlows) { var derivative = 0; for (var i = 1; i < cashFlows.length; i++) { // Starts from 1 because the derivative of cashFlows[0] is 0 derivative += -i * cashFlows[i] / Math.pow(1 + rate, i + 1); } return derivative; } // Newton-Raphson method to find IRR function irrNewtonRaphson(cashFlows, guessRate, maxIterations = 1000, tolerance = 1e-7) { var rate = guessRate; for (var i = 0; i < maxIterations; i++) { var npv = calculateNPV(rate, cashFlows); var derivative = derivativeNPV(rate, cashFlows); if (Math.abs(derivative) < tolerance) { // Derivative is too small, avoid division by zero return NaN; } var newRate = rate – npv / derivative; if (Math.abs(newRate – rate) < tolerance) { return newRate; // Converged } rate = newRate; } return NaN; // Did not converge within max iterations }

Leave a Comment