Skip to content

Home / Tools / NPV and IRR calculator

NPV and IRR calculator

By Sitraka Forler · Lecturer, Durham Business SchoolUpdated 16 October 2026 About this site

Net present value says how much a project adds in today's money at your cost of capital; the internal rate of return is the rate at which it adds nothing. Enter the cash flows, the outlay first, and a discount rate to get both, with the simple and discounted payback periods.

Free, no sign-up. Everything is computed in your browser: nothing you type is sent anywhere. Educational tool, not investment advice.

1. Calculator

The first value is today's flow (an outlay is negative), then one per year. Separate with commas, spaces or new lines; no thousands separators.

Your cost of capital or required return.

Table 1. Appraisal of 6 cash flows (t = 0 to 5) at 8.00% per period.
MeasureValueUnit
Net present value (NPV)278.27currency units
Internal rate of return (IRR)9.00% per period
Payback period3.87periods
Discounted payback period4.84periods
Undiscounted sum of flows3,000.00currency units

Positive NPV: at 8.00% the project returns more than it costs, adding 278.27 in today's money.

2. The formulas

NPV(r) = Σ_{t=0..T} CF_t / (1 + r)^t
Equation 1. Net present value at rate r, with the first cash flow at t = 0.
IRR: r such that NPV(r) = 0
Equation 2. Internal rate of return: the rate that sets the NPV to zero.
Payback = (t* − 1) + (−C_(t*−1)) / CF_t*
Equation 3. Payback: the last year the cumulative total C is negative, plus the share of the next year's flow needed to close it.

The first flow is undiscounted, as numpy_financial.npv does. Excel's NPV() discounts the first value it is given by a full period, so in a spreadsheet the outlay goes outside the function: =NPV(r, CF1:CFT) + CF0.

The IRR has no closed form: the calculator brackets the root and halves the bracket until it is narrower than 10⁻¹², the method the IRR page works by hand. Payback assumes each year's cash arrives evenly through the year; discounted payback runs the same count on present values.

3. Worked example

  1. A project costs €10,000 today and returns €2,000, €2,600, €2,800, €3,000 and €2,600 at the end of years 1 to 5.
  2. At 8%: 2,000 / 1.08 = 1,851.85; 2,600 / 1.1664 = 2,229.08; 2,800 / 1.259712 = 2,222.73; 3,000 / 1.36048896 = 2,205.09; 2,600 / 1.4693280768 = 1,769.52. They sum to €10,278.27, so NPV = +€278.27: accept.
  3. At 10% the same flows are worth €9,734.06 and NPV = −€265.94: reject. The IRR lies between, at 9.0016%, so the project clears any cost of capital below 9.00%.
  4. Payback: the running total is −8,000, −5,400, −2,600 after three years, and year 4 brings 3,000, so payback = 3 + 2,600 / 3,000 = 3.87 years.
  5. Discounted payback at 8%: the present values leave −1,491.25 after four years and year 5 adds 1,769.52, so 4 + 1,491.25 / 1,769.52 = 4.84 years.

Payback says the money comes back in under four years; only the NPV says whether it comes back with the 8% return it needed, and how much is left over. The glossary NPV page continues this example with a terminal value.

4. The Python behind it

import numpy as np
from scipy.optimize import brentq

cf = np.array([-10_000, 2_000, 2_600, 2_800, 3_000, 2_600])   # t = 0, 1, ..., 5
t = np.arange(cf.size)

def npv(rate):
    return (cf / (1 + rate) ** t).sum()

irr = brentq(npv, -0.99, 10)          # the rate where NPV crosses zero

def payback(flows):
    cum = np.cumsum(flows)
    j = np.argmax(cum >= 0)           # first period the total turns non-negative
    return j - 1 + -cum[j - 1] / flows[j]

print(f"NPV at 8%: {npv(0.08):.2f}")                         # 278.27
print(f"IRR: {irr:.4%}")                                     # 9.0016%
print(f"Payback: {payback(cf):.2f} years")                   # 3.87
print(f"Discounted payback: {payback(cf / 1.08 ** t):.2f}")  # 4.84
Listing 1. NPV, IRR and both payback periods in NumPy and SciPy; it prints the worked example's numbers.

5. Reading the result

  • When NPV and IRR disagree, for example between two projects of different size, follow the NPV: it is measured in money, the IRR in a rate.
  • Cash flows that change sign more than once can have several IRRs or none. The calculator warns you and the NPV still decides.
  • Payback ignores everything after the payback date. It measures how fast the outlay comes back, not whether the project is worth doing.
  • The rate must match the period of the flows: monthly flows need a monthly rate, and the IRR comes out per month.

Learn the concept

Code it yourself, free, in your browser

More: all calculators · every formula on one page