{
  "id": "comparative-advantage",
  "version": "bb0daca73222",
  "status": "published",
  "name": "Comparative Advantage Calculator",
  "question": "Who has the comparative advantage?",
  "summary": "Finds which of two producers has the comparative and the absolute advantage in each of two goods, from output or input per unit, with each opportunity cost.",
  "category": "finance",
  "subcategory": "business",
  "url": "https://www.acalculator.org/finance/comparative-advantage-calculator",
  "markdown": "https://www.acalculator.org/finance/comparative-advantage-calculator.md",
  "kind": "function",
  "method": "Output mode: A’s cost of good 1 = A₂ ÷ A₁ (units of good 2), of good 2 = A₁ ÷ A₂; the same for B. Input mode: output = 1 ÷ input first. Comparative advantage: the lower cost. Absolute advantage: the higher output (fewer inputs).",
  "assumptions": [
    "Each producer has the same resources (such as 100 worker hours), and costs per unit stay the same at any output.",
    "Two producers, two goods."
  ],
  "inputs": {
    "$schema": "https://json-schema.org/draft/2020-12/schema",
    "type": "object",
    "properties": {
      "basis": {
        "title": "Numbers are",
        "description": "Output each producer makes with the same resources, or the resources (hours, workers) each needs per unit.",
        "type": "string",
        "enum": [
          "output",
          "input"
        ]
      },
      "na": {
        "title": "Producer A",
        "description": "The first producer: a country, a firm or a person.",
        "type": "string",
        "maxLength": 40
      },
      "nb": {
        "title": "Producer B",
        "description": "The second producer.",
        "type": "string",
        "maxLength": 40
      },
      "g1": {
        "title": "Good 1",
        "description": "The first good.",
        "type": "string",
        "maxLength": 40
      },
      "g2": {
        "title": "Good 2",
        "description": "The second good.",
        "type": "string",
        "maxLength": 40
      },
      "a1": {
        "title": "A: good 1",
        "description": "Output with the same resources, or resources needed per unit, as chosen above.",
        "type": "number",
        "minimum": 0.000001,
        "maximum": 1000000000000
      },
      "a2": {
        "title": "A: good 2",
        "description": "Output with the same resources, or resources needed per unit, as chosen above.",
        "type": "number",
        "minimum": 0.000001,
        "maximum": 1000000000000
      },
      "b1": {
        "title": "B: good 1",
        "description": "Output with the same resources, or resources needed per unit, as chosen above.",
        "type": "number",
        "minimum": 0.000001,
        "maximum": 1000000000000
      },
      "b2": {
        "title": "B: good 2",
        "description": "Output with the same resources, or resources needed per unit, as chosen above.",
        "type": "number",
        "minimum": 0.000001,
        "maximum": 1000000000000
      }
    }
  },
  "outputs": {
    "comparative1": {
      "label": "Comparative advantage in good 1",
      "description": "The producer with the lower opportunity cost of good 1.",
      "format": "text"
    },
    "comparative2": {
      "label": "Comparative advantage in good 2",
      "description": "The producer with the lower opportunity cost of good 2.",
      "format": "text"
    },
    "absolute1": {
      "label": "Absolute advantage in good 1",
      "description": "The producer that makes more of good 1 with the same resources.",
      "format": "text"
    },
    "absolute2": {
      "label": "Absolute advantage in good 2",
      "description": "The producer that makes more of good 2 with the same resources.",
      "format": "text"
    },
    "summary": {
      "label": "Comparative advantage",
      "description": "Who has the comparative advantage in each good, by name.",
      "format": "text"
    },
    "costA1": {
      "label": "A: cost of 1 unit of good 1",
      "description": "Units of good 2 that A gives up to make one unit of good 1.",
      "format": "number"
    },
    "costB1": {
      "label": "B: cost of 1 unit of good 1",
      "description": "Units of good 2 that B gives up to make one unit of good 1.",
      "format": "number"
    },
    "costA2": {
      "label": "A: cost of 1 unit of good 2",
      "description": "Units of good 1 that A gives up to make one unit of good 2.",
      "format": "number"
    },
    "costB2": {
      "label": "B: cost of 1 unit of good 2",
      "description": "Units of good 1 that B gives up to make one unit of good 2.",
      "format": "number"
    }
  },
  "defaultAnswer": {
    "inputs": {
      "basis": "output",
      "na": "Saudi Arabia",
      "nb": "United States",
      "g1": "oil",
      "g2": "corn",
      "a1": 100,
      "a2": 25,
      "b1": 50,
      "b2": 100
    },
    "outputs": {
      "comparative1": "Saudi Arabia",
      "comparative2": "United States",
      "absolute1": "Saudi Arabia",
      "absolute2": "United States",
      "summary": "Saudi Arabia in oil; United States in corn",
      "costA1": 0.25,
      "costB1": 2,
      "costA2": 4,
      "costB2": 0.5
    },
    "text": "Comparative advantage: Saudi Arabia in oil; United States in corn."
  },
  "examples": [
    {
      "given": {
        "basis": "output",
        "na": "Saudi Arabia",
        "nb": "United States",
        "g1": "oil",
        "g2": "corn",
        "a1": 100,
        "a2": 25,
        "b1": 50,
        "b2": 100
      },
      "expect": {
        "comparative1": "Saudi Arabia",
        "comparative2": "United States",
        "absolute1": "Saudi Arabia",
        "absolute2": "United States",
        "costA1": 0.25,
        "costB1": 2,
        "costA2": 4,
        "costB2": 0.5,
        "summary": "Saudi Arabia in oil; United States in corn"
      },
      "source": "OpenStax, Principles of Economics 3e, §33.1, Tables 33.2 and 33.4 (Saudi Arabia 100 barrels or 25 bushels, US 50 barrels or 100 bushels; oil costs ¼ bushel and 2 bushels); https://openstax.org/books/principles-economics-3e/pages/33-1-absolute-and-comparative-advantage"
    },
    {
      "given": {
        "basis": "input",
        "na": "United States",
        "nb": "Mexico",
        "g1": "shoes",
        "g2": "refrigerators",
        "a1": 4,
        "a2": 1,
        "b1": 5,
        "b2": 4
      },
      "expect": {
        "comparative1": "Mexico",
        "comparative2": "United States",
        "absolute1": "United States",
        "absolute2": "United States",
        "costA1": 4,
        "costB1": 1.25,
        "costA2": 0.25,
        "costB2": 0.8,
        "summary": "Mexico in shoes; United States in refrigerators"
      },
      "source": "OpenStax, Principles of Economics 3e, §33.2, Table 33.7 (US 4 and 1 workers, Mexico 5 and 4; the US has a comparative advantage in refrigerators, Mexico in shoes); https://openstax.org/books/principles-economics-3e/pages/33-2-what-happens-when-a-country-has-an-absolute-advantage-in-all-goods"
    },
    {
      "given": {
        "basis": "output",
        "a1": 10,
        "a2": 20,
        "b1": 5,
        "b2": 10
      },
      "expect": {
        "comparative1": "Neither (equal)",
        "comparative2": "Neither (equal)",
        "absolute1": "A",
        "costA1": 2,
        "costB1": 2
      },
      "source": "OpenStax, Principles of Economics 3e, §33.1 (comparative advantage is a lower opportunity cost); hand calculation in content.mdx; https://openstax.org/books/principles-economics-3e/pages/33-1-absolute-and-comparative-advantage"
    }
  ],
  "sources": [
    "OpenStax. Principles of Economics 3e, §33.1 Absolute and Comparative Advantage (Tables 33.1, 33.2 and 33.4, oil and corn), retrieved 2026-10-18. https://openstax.org/books/principles-economics-3e/pages/33-1-absolute-and-comparative-advantage",
    "OpenStax. Principles of Economics 3e, §33.2 What Happens When a Country Has an Absolute Advantage in All Goods (Table 33.7, shoes and refrigerators), retrieved 2026-10-18. https://openstax.org/books/principles-economics-3e/pages/33-2-what-happens-when-a-country-has-an-absolute-advantage-in-all-goods"
  ],
  "related": [
    "consumer-surplus",
    "deadweight-loss",
    "gdp",
    "opportunity-cost"
  ],
  "changelog": []
}
