Economics calculator

Comparative Advantage Calculator

Enter what two producers can each make of two goods, and see each one's opportunity cost, who has the absolute advantage, who has the comparative advantage, and the trade rate range where specializing and trading leaves both sides better off — with a worked gains-from-trade figure, not just a verdict.

Opportunity cost for both producers Absolute vs. comparative advantage Mutually beneficial trade range Transparent formula

A teaching model — real trade involves far more than two goods.

Comparative advantage is about opportunity cost, not raw output — even a producer that makes more of everything can still gain from specializing in whichever good it gives up the least to produce, and trading for the rest.

Calculator

Producers & goods

Output per unit of resource (labor, land, or time)

Illustrative trade

Must be strictly between 1 and 2 for both sides to gain.

Country A has the absolute advantage in both goods, yet comparative advantage still splits between the two producers — this is the central, non-obvious result of the model: absolute advantage in everything doesn't remove the gains from trade.

Comparative advantage

Wheat: Country B

Cloth: Country A

Absolute advantage

Wheat: Country A

Cloth: Country A

Country A

Country B

Opp. cost of Wheat

2 Cloth

1 Cloth

Opp. cost of Cloth

0.50 Wheat

1 Wheat

Gains from trade at 1.50 Cloth/Wheat

Country B specializes in Wheat, Country A specializes in Cloth. Trading 3 Wheat for 4.50 Cloth: the Wheat importer pays 4.50 Cloth instead of the 6 Cloth it would cost to produce that Wheat domestically — a saving of 1.50 Cloth. Likewise, the Cloth importer saves 1.50 Wheat versus producing that Cloth itself.

At a glance

Formula shown
Opportunity cost of a good = the other good's output ÷ this good's output. Lower opportunity cost = comparative advantage.
Scenario support
Any two producers, two goods, and a trade rate within the mutually beneficial range.
Educational estimate
Planning support from the values you enter — not professional advice.

How to read your result

The two advantage cards answer different questions: absolute advantage is about who produces more, comparative advantage is about who gives up less — and they don't have to point to the same producer. The opportunity-cost table underneath is where the comparative advantage numbers actually come from, so you can check the logic yourself rather than trust a verdict. The gains-from-trade panel only appears when a comparative advantage exists (identical opportunity costs mean there's nothing to gain from trading), and shows what each side saves at your chosen rate and quantity, compared to producing that amount domestically instead.

The formula

Opportunity cost

opp. cost of X = output of Y ÷ output of X

How much Y a producer gives up to make one more unit of X, from what it could produce of each with the same resource.

Gains from trade

gain = (quantity × domestic opp. cost) − (quantity actually paid via trade)

Positive whenever the trade rate sits between the two producers' opportunity costs.

Worked example

Country A can produce 10 units of Wheat or 20 units of Cloth with its resource; Country B can produce 6 Wheat or 6 Cloth. A's opportunity cost of Wheat is 2 Cloth (20÷10); B's is just 1 Cloth (6÷6) — so B has the comparative advantage in Wheat, even though A produces more of both goods outright (A has the absolute advantage in both). A's opportunity cost of Cloth is 0.5 Wheat versus B's 1 Wheat, so A has the comparative advantage in Cloth. At a trade rate of 1.5 Cloth per Wheat (the midpoint of the 1–2 mutually beneficial range), trading 3 Wheat for 4.5 Cloth saves the Wheat-importer 1.5 Cloth and the Cloth-importer 1.5 Wheat, compared to each producing that amount domestically instead.

Assumptions

  • Each producer has a fixed amount of one resource (labor, land, or time) that can be split between producing either good, with constant output per unit of resource — no economies of scale.
  • Opportunity cost of a good is the amount of the other good given up to produce one more unit of it, derived directly from the two output figures you enter.
  • A trade rate strictly between the two producers’ opportunity costs for a good makes both sides better off than producing everything themselves — this is a general mathematical result, true for any quantity traded at such a rate.
  • The gains-from-trade figures compare the actual trade to each importer’s own domestic opportunity cost for the traded quantity — not to a specific pre-trade consumption bundle, which depends on assumptions this calculator doesn’t need to make.

Limitations

  • Models exactly two goods and two producers — real economies produce and trade far more than two goods with far more than two trading partners.
  • Assumes constant opportunity cost (a straight-line production possibility frontier) — real production usually shows increasing opportunity costs as resources shift between uses.
  • Ignores transport costs, tariffs, exchange rates, and other frictions that affect real trade but have nothing to do with comparative advantage itself.
  • Assumes resources can move freely between producing either good — in reality, retraining workers or repurposing land and capital takes time and has its own cost.
  • Is a teaching model of gains from specialization, not a forecast of what any real country or company should actually produce.

Frequently asked questions

What is a comparative advantage calculator?

A tool that takes two producers’ output of two goods and works out each producer’s opportunity cost, which one has the comparative advantage in each good, which has the absolute advantage, and the range of trade rates where specializing and trading benefits both sides.

What is comparative advantage?

The ability to produce a good at a lower opportunity cost than another producer — not necessarily to produce more of it in absolute terms. A producer has comparative advantage in whichever good it gives up the least of the other good to make.

What is absolute advantage?

Simply producing more of a good than another producer, using the same amount of resource. It’s a comparison of raw output, unlike comparative advantage, which compares opportunity costs.

What’s the difference between absolute and comparative advantage?

Absolute advantage asks "who makes more?" — comparative advantage asks "who gives up less to make it?" A producer can have the absolute advantage in both goods and still not have the comparative advantage in both — in fact it mathematically cannot, since a lower opportunity cost in one good always means a higher opportunity cost in the other, for the same producer.

How do you calculate comparative advantage?

Divide each producer’s output of one good by its output of the other to get the opportunity cost of each good, for each producer. Whichever producer has the lower opportunity cost for a given good has the comparative advantage in it — the calculator above does this from the four output numbers you enter.

How does opportunity cost relate to comparative advantage?

Opportunity cost is what comparative advantage is measured by — not output, not skill, but how much of one good a producer must give up to make one more unit of the other. The Opportunity Cost Calculator covers the general two-choice version of this idea; this page applies it specifically to two producers and two goods to find the basis for trade.

Can one producer have both absolute and comparative advantage?

Yes, in one good — but never in both goods at once. A producer can be absolutely better at making everything, and the calculator’s example shows exactly this case, yet comparative advantage still splits between the two producers because opportunity costs are always mirror images of each other for the same producer. This is the central, often counterintuitive result of the model: even the most productive economy still gains from specializing and trading.

What is a mutually beneficial trade rate?

Any trade rate strictly between the two producers’ opportunity costs for the traded good. Inside that range, both sides pay less through trade than they would to produce the good themselves — outside it, one side would be better off not trading at all.

What is revealed comparative advantage, and does this calculator compute it?

No — revealed comparative advantage (RCA) is a different, empirical measure used in real trade statistics, comparing a country’s actual export share of a good to that good’s share of world trade. This calculator implements the classical theoretical model (opportunity cost from output figures you supply), not the RCA index, which requires real trade-flow data this tool doesn’t use.

Should I use this or the Opportunity Cost Calculator?

Use the Opportunity Cost Calculator for a single decision-maker choosing between two options. Use this page when you’re comparing two separate producers and asking whether specialization and trade between them makes both better off — the same underlying idea, applied to trade instead of a single choice.

Related calculators

Tools that build on the same economics fundamentals:

Sources

Disclaimer

This calculator is for educational purposes only. It illustrates the classic two-producer, two-good Ricardian model of comparative advantage — a simplified teaching model, not a forecast or a real trade-policy tool. Real-world trade involves many goods, transport costs, tariffs, exchange rates, factor mobility, and changing productivity, none of which this model captures. It does not calculate the empirical "revealed comparative advantage" index used in trade statistics — see the FAQ below for that distinction.

How we calculate · Found an error? email us

Authorship & verification

Written and maintained by

  • Formula and examples verified on 16 August 2026
  • Educational estimate only

Add this calculator to your site

Responsive embed — and private: nothing your visitors type leaves their browser.