What this calculator does
This calculator applies the economic concept of comparative advantage to two producers, each capable of making two goods. It finds each producer's opportunity cost for a good — how much of the other good it must give up to make one more unit — and identifies which producer should specialize in which good so that trade leaves both sides with more total output than either could reach alone.
The formula
For a producer that can make either x units of Good 1 or y units of Good 2 with the same fixed resources (labor, time, or capital), the opportunity cost of Good 1 in terms of Good 2 is:
Opportunity cost of Good 1 = y / x (units of Good 2 forgone per unit of Good 1)
Compute this ratio for both Producer A and Producer B. The producer with the lower opportunity cost of Good 1 has the comparative advantage in Good 1; the other producer automatically has the comparative advantage in Good 2 (its opportunity cost of Good 1 is higher, so its opportunity cost of Good 2 — the reciprocal — is lower). This holds even if one producer is more productive at everything in absolute terms; comparative advantage is about relative trade-offs, not raw output.
Worked example
Say Producer A can make 10 units of Good 1 or 5 units of Good 2 per day, while Producer B can make 4 units of Good 1 or 8 units of Good 2 per day. Producer A's opportunity cost of Good 1 is 5/10 = 0.50 units of Good 2; Producer B's is 8/4 = 2.00 units of Good 2. Because 0.50 is lower, Producer A has the comparative advantage in Good 1, and Producer B has the comparative advantage in Good 2. If each producer had instead split its resources evenly between the two goods, combined output would be 7 units of Good 1 and 6.5 units of Good 2. Full specialization — Producer A making only Good 1, Producer B making only Good 2 — raises combined output to 10 units of Good 1 and 8 units of Good 2, a joint gain of 3 units of Good 1 and 1.5 units of Good 2 that the two producers can then divide through trade.
Gains from trade
Specialization only helps if both sides can trade at a price that beats what each could achieve alone. That price — the terms of trade — must fall strictly between the two producers' opportunity costs of Good 1. In the example above, any trade rate between 0.50 and 2.00 units of Good 2 per unit of Good 1 leaves both producers better off than producing everything themselves. If the two opportunity costs are equal, no such price exists and there is nothing to gain from specializing.
Absolute versus comparative advantage
Absolute advantage is about who produces more of a good with the same resources. Comparative advantage is about who gives up less of the other good to do so. A producer can be more productive at both goods (have an absolute advantage in both) and still gain from trading, because what matters for mutually beneficial trade is the relative opportunity cost, not the absolute output level.