{
  "id": "opportunity-cost",
  "version": "21228c96ca2f",
  "status": "published",
  "name": "Opportunity Cost Calculator",
  "question": "What is opportunity cost?",
  "summary": "Computes the opportunity cost of a choice: the return given up against the best other option, or the growth money spent now would have earned if invested.",
  "category": "finance",
  "subcategory": "business",
  "url": "https://www.acalculator.org/finance/opportunity-cost-calculator",
  "markdown": "https://www.acalculator.org/finance/opportunity-cost-calculator.md",
  "kind": "function",
  "method": "Two options: opportunity cost = return of the best option passed up − return of the option chosen. Spend or invest: forgone value = amount × (1 + rate)^years; opportunity cost = forgone value − amount.",
  "assumptions": [
    "Only money counts: time, risk and enjoyment are left out.",
    "Invested money compounds once a year at a steady rate, with no tax or fees.",
    "Two-option sums are exact on the typed decimals; compounding is a float power. Money shows to the cent, halves up."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "mode": {
        "title": "Compare",
        "description": "Two options with known returns, or spending money now against investing it.",
        "type": "string",
        "enum": [
          "options",
          "invest"
        ]
      },
      "chosen": {
        "title": "Return of the option you chose",
        "description": "What the chosen option earns. Negative for a loss.",
        "type": "number",
        "x-unit": "USD",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "other": {
        "title": "Return of the best option you passed up",
        "description": "What the next best option would have earned. Negative for a loss.",
        "type": "number",
        "x-unit": "USD",
        "minimum": -1000000000000,
        "maximum": 1000000000000
      },
      "amount": {
        "title": "Money spent now",
        "description": "The amount you spend instead of investing.",
        "type": "number",
        "x-unit": "USD",
        "minimum": 0,
        "maximum": 1000000000000
      },
      "rate": {
        "title": "Yearly return if invested",
        "description": "The return the money would earn each year, compounded yearly. Negative for a loss.",
        "type": "number",
        "x-unit": "percent",
        "minimum": -99,
        "maximum": 100
      },
      "years": {
        "title": "Years",
        "description": "How long the money would have stayed invested.",
        "type": "integer",
        "minimum": 1,
        "maximum": 100
      }
    }
  },
  "outputs": {
    "cost": {
      "label": "Opportunity cost",
      "description": "What the choice gives up: the other option’s return minus the chosen one, or the growth given up.",
      "format": "money"
    },
    "forgone": {
      "label": "Value of the option passed up",
      "description": "The return of the best other option, or what the money would have grown to.",
      "format": "money"
    },
    "better": {
      "label": "Better choice",
      "description": "Which option earns more.",
      "format": "text"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "mode": "options",
      "chosen": 4000,
      "other": 6500,
      "amount": 10000,
      "rate": 7,
      "years": 10
    },
    "outputs": {
      "cost": 2500,
      "forgone": 6500,
      "better": "The option you passed up"
    },
    "text": "The opportunity cost of this choice is $2,500.00: the option passed up is worth $6,500.00."
  },
  "examples": [
    {
      "given": {
        "mode": "options",
        "chosen": 4000,
        "other": 6500
      },
      "expect": {
        "cost": 2500,
        "forgone": 6500,
        "better": "The option you passed up"
      },
      "source": "OpenStax, Principles of Economics 3e, 2.1 How Individuals Make Choices Based on Their Budget Constraint (opportunity cost is the value of the next best alternative given up). https://openstax.org/books/principles-economics-3e/pages/2-1-how-individuals-make-choices-based-on-their-budget-constraint; hand calculation in content.mdx: 6,500 − 4,000 = 2,500"
    },
    {
      "given": {
        "mode": "options",
        "chosen": 12000.75,
        "other": 9000
      },
      "expect": {
        "cost": -3000.75,
        "better": "The option you chose"
      },
      "source": "OpenStax, Principles of Economics 3e, 2.1 How Individuals Make Choices Based on Their Budget Constraint (opportunity cost is the value of the next best alternative given up). https://openstax.org/books/principles-economics-3e/pages/2-1-how-individuals-make-choices-based-on-their-budget-constraint; hand calculation in content.mdx: 9,000 − 12,000.75 = −3,000.75"
    },
    {
      "given": {
        "mode": "invest",
        "amount": 1000,
        "rate": 3,
        "years": 4
      },
      "expect": {
        "forgone": 1125.50881,
        "cost": 125.50881
      },
      "source": "OpenStax, Principles of Finance, 7.2 Time Value of Money (TVM) Basics (FV = PV × (1 + i)^n). https://openstax.org/books/principles-finance/pages/7-2-time-value-of-money-tvm-basics; OpenStax 7.3 grows $1,000 at 3% for 4 years to $1,125.51. Hand calculation in content.mdx: 1,000 × 1.03⁴ = 1,125.50881"
    },
    {
      "given": {
        "mode": "invest",
        "amount": 10000,
        "rate": 7,
        "years": 10
      },
      "expect": {
        "cost": 9671.513572895654
      },
      "source": "OpenStax, Principles of Finance, 7.2 Time Value of Money (TVM) Basics (FV = PV × (1 + i)^n). https://openstax.org/books/principles-finance/pages/7-2-time-value-of-money-tvm-basics; hand calculation in content.mdx: 10,000 × 1.07¹⁰ = 19,671.51; minus 10,000"
    }
  ],
  "sources": [
    "OpenStax, Principles of Economics 3e, 2.1 How Individuals Make Choices Based on Their Budget Constraint: opportunity cost is the value of the next best alternative; examples in money and time. https://openstax.org/books/principles-economics-3e/pages/2-1-how-individuals-make-choices-based-on-their-budget-constraint (retrieved 2026-10-05)",
    "OpenStax, Principles of Finance, 7.2 Time Value of Money (TVM) Basics: future value of a single amount, FV = PV × (1 + i)^n. https://openstax.org/books/principles-finance/pages/7-2-time-value-of-money-tvm-basics (retrieved 2026-10-05)",
    "OpenStax, Principles of Finance, 7.3 Methods for Solving Time Value of Money Problems: $1,000 at 3% for 4 years grows to $1,125.51. https://openstax.org/books/principles-finance/pages/7-3-methods-for-solving-time-value-of-money-problems (retrieved 2026-10-05)"
  ],
  "related": [
    "roi",
    "compound-interest",
    "future-value",
    "wacc"
  ],
  "changelog": []
}
