Net Present Value (NPV) Calculator with Discount Rate
This Net Present Value (NPV) calculator helps investors and business analysts determine the profitability of a prospective investment or project. By inputting an initial investment cost, a required discount rate, and projected future cash flows for up to five years, this tool calculates current value of those future returns.
This is your required rate of return or cost of capital.
Projected Future Net Cash Flows ($)
Result will appear here…
function calculateNPV() {
// Get input values
var initialInvestmentVal = document.getElementById('npvInitialInvestment').value;
var discountRateVal = document.getElementById('npvDiscountRate').value;
var cf1Val = document.getElementById('npvCf1').value;
var cf2Val = document.getElementById('npvCf2').value;
var cf3Val = document.getElementById('npvCf3').value;
var cf4Val = document.getElementById('npvCf4').value;
var cf5Val = document.getElementById('npvCf5').value;
// Parse values, defaulting empty cash flows to 0
var initialInvestment = parseFloat(initialInvestmentVal);
var discountRatePercent = parseFloat(discountRateVal);
var cf1 = cf1Val === "" ? 0 : parseFloat(cf1Val);
var cf2 = cf2Val === "" ? 0 : parseFloat(cf2Val);
var cf3 = cf3Val === "" ? 0 : parseFloat(cf3Val);
var cf4 = cf4Val === "" ? 0 : parseFloat(cf4Val);
var cf5 = cf5Val === "" ? 0 : parseFloat(cf5Val);
// Validate critical inputs
if (isNaN(initialInvestment) || isNaN(discountRatePercent)) {
document.getElementById('npvResult').innerHTML = "Please enter valid numbers for Initial Investment and Discount Rate.";
return;
}
// Convert percentage to decimal rate
var r = discountRatePercent / 100;
// Calculate Present Value (PV) for each year's cash flow
// Formula: PV = Cash Flow / (1 + r)^t
var pv1 = cf1 / Math.pow((1 + r), 1);
var pv2 = cf2 / Math.pow((1 + r), 2);
var pv3 = cf3 / Math.pow((1 + r), 3);
var pv4 = cf4 / Math.pow((1 + r), 4);
var pv5 = cf5 / Math.pow((1 + r), 5);
// Sum of future Present Values
var totalFuturePV = pv1 + pv2 + pv3 + pv4 + pv5;
// Calculate Net Present Value
// Formula: NPV = Sum of Future PVs – Initial Investment
var npv = totalFuturePV – initialInvestment;
// Format output
var formattedNPV = npv.toFixed(2).replace(/\d(?=(\d{3})+\.)/g, '$&,');
var resultHtml = "Net Present Value (NPV): $" + formattedNPV + "";
// Add interpretation
if (npv > 0) {
resultHtml += "The project is projected to be profitable relative to the discount rate.";
} else if (npv < -0.01) { // Using slight tolerance for floating point comparison
resultHtml += "The project is projected to result in a loss relative to the discount rate.";
} else {
resultHtml += "The project is projected to break even.";
}
document.getElementById('npvResult').innerHTML = resultHtml;
}
Understanding Net Present Value (NPV)
Net Present Value is a core concept in finance and capital budgeting. It addresses the "time value of money"—the idea that a dollar received today is worth more than a dollar received in the future because today's dollar can be invested to earn interest.
When evaluating an investment, you cannot simply compare the upfront cost with future earnings directly. You must "discount" those future earnings back to what they would be worth today. The NPV calculation subtracts the initial investment cost from the sum of these discounted future cash flows.
Key Inputs Explained:
Initial Investment Cost: This is the total amount of capital required at the start of the project (time period 0). This is treated as a cash outflow. For example, purchasing new machinery for $50,000.
Annual Discount Rate: This is crucial. It represents the minimum rate of return you require to undertake the project. It often reflects the cost of borrowing money (interest rate) or the return you could get from an alternative, similarly risky investment. A higher discount rate reduces the present value of future cash flows.
Future Cash Flows: These are the net amounts of cash you expect the project to generate in subsequent years (Revenue minus operating costs).
Interpreting the Result
The result of the NPV calculation tells you the value added or lost by the investment in today's dollars:
Positive NPV (> $0): The projected earnings (in today's dollars) exceed the anticipated costs. This is generally considered a good investment that will add value to the company.
Negative NPV (< $0): The projected costs exceed the anticipated earnings in today's dollars. Undertaking this project would likely reduce value.
Zero NPV: The project is expected to exactly break even, earning exactly the discount rate utilized.