Skip to content
πŸ› οΈToolsShed

IRR Calculator

Calculate the Internal Rate of Return (IRR) for a series of cash flows.

Future Cash Flows

Year 1
Year 2
Year 3
Year 4

About this tool

The Internal Rate of Return (IRR) is a critical metric for evaluating the profitability and efficiency of investments or projects. This calculator determines the discount rate at which the net present value (NPV) of all cash flows equals zero, giving you a single percentage that represents your investment's annual return. Understanding IRR helps investors and finance professionals compare different investment opportunities on an equal basis, regardless of their size or timeline.

To use this calculator, enter your initial investment (typically a negative value) and all subsequent cash flows in chronological order with their respective years. The tool then iteratively solves for the IRR using numerical methods. IRR is commonly used to evaluate capital investments, business acquisitions, real estate deals, and project feasibility. It's particularly valuable when you need to decide between competing investment opportunities or assess whether a project meets your required rate of return.

Keep in mind that IRR assumes reinvestment of cash flows at the IRR rate itself, which may not always be realistic; modified IRR (MIRR) can address this in complex scenarios. Additionally, IRR may produce multiple solutions for unconventional cash flow patterns. This calculator provides the primary IRR value and is most reliable when cash flows follow a conventional pattern with an initial outflow followed by inflows.

Frequently Asked Questions

Code Implementation

def npv(rate: float, cash_flows: list) -> float:
    """Net Present Value at given rate."""
    return sum(cf / (1 + rate) ** t for t, cf in enumerate(cash_flows))

def irr(cash_flows: list, max_iter: int = 1000, tol: float = 1e-7) -> float | None:
    """Internal Rate of Return via Newton-Raphson iteration."""
    # Check sign change
    positives = any(cf > 0 for cf in cash_flows)
    negatives = any(cf < 0 for cf in cash_flows)
    if not (positives and negatives):
        return None

    rate = 0.1  # initial guess
    for _ in range(max_iter):
        f = npv(rate, cash_flows)
        # Derivative: d/dr NPV = sum(-t * cf / (1+r)^(t+1))
        df = sum(-t * cf / (1 + rate) ** (t + 1) for t, cf in enumerate(cash_flows))
        if df == 0:
            break
        new_rate = rate - f / df
        if abs(new_rate - rate) < tol:
            return new_rate
        rate = new_rate
    return None

# Example: invest $1000, receive $300, $400, $500 over 3 years
cash_flows = [-1000, 300, 400, 500]
result = irr(cash_flows)
if result is not None:
    print(f"IRR = {result * 100:.2f}%")
    print(f"NPV at IRR β‰ˆ {npv(result, cash_flows):.6f}")  # should be ~0

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.