Comparative Advantage Calculator

Enter how much of two goods two producers can make in the same time, and see who should specialize in what — with every opportunity cost shown.

Maximum output if each producer spent all their time on one good (same time period for everyone):

AB

Why Comparative Advantage Matters

Comparative advantage is the idea, set out by David Ricardo in 1817, that two parties gain from trade even when one of them is better at producing everything. What matters is not who is faster, but who gives up less to produce a good. It's a staple of introductory economics courses and AP Macro/Micro exams, and it's just as useful for deciding how to split chores in a household or tasks on a team. Most homework mistakes come from flipping an opportunity cost upside down, so this calculator shows every step.

Step by Step

  1. For each producer, enter the most of each good they could make if they spent all their time on it (the "output" method). If your problem gives hours needed per unit instead, convert first: units per period = hours available ÷ hours per unit.
  2. The calculator finds each producer's opportunity cost of one unit of X (how much Y they give up) and of one unit of Y.
  3. It compares them: the lower opportunity cost wins the comparative advantage in that good. Higher raw output wins the absolute advantage.
  4. It gives the range of prices at which trading makes both sides better off, and the extra output gained by specializing.

The Formula Explained

If A can make Xₐ units of X or Yₐ units of Y, then each unit of X costs A Yₐ ÷ Xₐ units of Y, and each unit of Y costs Xₐ ÷ Yₐ units of X. The two costs are always reciprocals, which is why one producer can never have the comparative advantage in both goods. Trade benefits both whenever the price of one X, measured in Y, falls strictly between the two producers' opportunity costs of X.

A Real Example

Ana can make 6 shirts or 4 cakes a day; Ben can make 2 shirts or 2 cakes. Ana has the absolute advantage in both. But a shirt costs Ana 4 ÷ 6 = 0.67 cakes and costs Ben 1 cake, so Ana has the comparative advantage in shirts; a cake costs Ana 1.5 shirts and Ben only 1 shirt, so Ben has the comparative advantage in cakes. Any price between 0.67 and 1 cake per shirt works for both. If each splits the day in half they make 4 shirts and 3 cakes together. If Ben bakes full time (2 cakes) and Ana bakes the one missing cake (a quarter of her day) and sews for the rest (4.5 shirts), the pair has the same 3 cakes and half a shirt more — that extra half shirt is the gain from trade.

Edge Cases to Watch For

If both producers have the same opportunity cost, neither has a comparative advantage and specializing gains nothing; the calculator says so. A zero for one good means that producer cannot make it at all, so their opportunity cost of the other good is zero and they should specialize in it. The model assumes constant opportunity costs (straight-line production possibilities), no transport costs and full employment — the textbook setup, not a forecast of real-world trade flows. The "gain from specializing" compares against both producers splitting their time evenly and holds total Y fixed; other starting points give different gains, but the direction is always the same.

Related calculators

Rental Yield Calculator

Get your gross and net rental yield from a property's value, rent, and running costs.

ETF Overlap Calculator

Enter the weight of each shared holding in both funds to calculate the true overlap between two ETFs.

Chubby FIRE Calculator

Find your Chubby FIRE number and see how long it'll take to get there at your current savings rate.

Platinum Scrap Calculator

Enter weight, purity, and spot price to get the melt value of your platinum scrap or jewelry.