Comparative Advantage Calculator
Turn a two-producer, two-good output table into opportunity costs and find who should specialise.
Absolute advantage: Producer A in X, Producer A in Y (higher raw output).
- Producer A
- 2 Y
- Producer B
- 1 Y
Lower cost → Producer B has the comparative advantage in X.
- Producer A
- 0.5 X
- Producer B
- 1 X
Lower cost → Producer A has the comparative advantage in Y.
Comparative advantage belongs to whoever gives up the least to make a good — the lowest opportunity cost. If A makes 10 X or 20 Y and B makes 4 X or 4 Y, A’s cost per X is 2 Y while B’s is 1 Y, so B specialises in X and A in Y — even though A out-produces B on both (absolute advantage).
What comparative advantage is
Comparative advantage is the idea that a producer should make the good they sacrifice the least to produce. Every unit of one good you make costs you the other good you could have made instead — that trade-off is the opportunity cost. Whoever faces the lower opportunity cost for a good has the comparative advantage in it and should specialise there, then trade for the rest. This is the engine behind gains from trade, and it holds even when one side is better at making everything.
X and Y are how many units of each good a producer can make with the same time or resources. The good you divide by is the one you are making; the result is how much of the other good you give up.
Worked example
Producer A can make 10 X or 20 Y; Producer B can make 4 X or 4 Y with the same resources.
- 1 Write the output table. List how much of each good every producer can make: A = 10 X or 20 Y, B = 4 X or 4 Y.
- 2 Cost of one X = Y ÷ X. A: 20 ÷ 10 = 2 Y per X. B: 4 ÷ 4 = 1 Y per X.
- 3 Cost of one Y = X ÷ Y. A: 10 ÷ 20 = 0.5 X per Y. B: 4 ÷ 4 = 1 X per Y.
- 4 Pick the lower cost for each good. X is cheaper for B (1 Y < 2 Y); Y is cheaper for A (0.5 X < 1 X).
- 5 Specialise and trade. B makes X, A makes Y, then they trade — total output rises even though A has the absolute advantage in both goods.
Opportunity-cost comparison (A 10X/20Y · B 4X/4Y)
Read down each column: the producer with the lower opportunity cost has the comparative advantage in that good.
| Producer | Cost of 1 X (in Y) | Cost of 1 Y (in X) |
|---|---|---|
| A | 2 | 0.5 ← lower |
| B | 1 ← lower | 1 |
| Advantage | B specialises in X | A specialises in Y |
Why the “worse” producer still gains
In the example A has the absolute advantage in both goods — 10 > 4 units of X and 20 > 4 units of Y. Absolute advantage just compares raw output, so it can sit entirely with one side. Comparative advantage compares opportunity costs, and those cannot both favour the same producer: if one good is relatively cheap for you, the other is relatively cheap for the other side. That is why each producer always has a comparative advantage in exactly one good, and why specialisation plus trade leaves both better off.
This is David Ricardo’s classic argument from 1817. Even a producer who is worse at everything in absolute terms is still comparatively better at something, so there are always gains from trade — the point that turns a lopsided output table into a case for specialisation.