Lelifi·tools

Comparative Advantage Calculator

Saudi Arabia gives up 0.25 bushels of corn per barrel of oil, against 2 bushels for the United States. That lower opportunity cost gives it the comparative advantage in oil, while the United States holds the advantage in corn at half a barrel per bushel.

Enter production data for two countries and two goods. The calculator returns all four opportunity costs, the comparative advantage for each side, and the trade price range.

By the Lelifi editors ·

Key takeaways

Opportunity cost in the OpenStax oil and corn exampleSaudi Arabia: 1 hour per barrel of oil, 4 hours per bushel of cornOpportunity cost of 1 barrel for Saudi Arabia = 1 / 4 = 0.25 bushelsUnited States: 2 hours per barrel, 1 hour per bushelOpportunity cost of 1 barrel for the United States = 2 / 1 = 2 bushels0.25 beats 2, so Saudi Arabia has the comparative advantage in oilLower opportunity cost wins, even when the other country produces more of both goods.
The oil and corn opportunity costs step by step: 1 over 4 equals 0.25 bushels for Saudi Arabia against 2 bushels for the United States.
Output per worker: wheat in tons or cars per yearwheatcarsUnited States: 12 wheat or 6 carsBrazil: 8 wheat or 2 cars08120261 car costs the United States 2 tons of wheat1 car costs Brazil 4 tons of wheat
Output per worker for the United States and Brazil. The steeper United States line is the low-cost car maker: 2 tons of wheat per car against 4.
On this page
  1. What comparative advantage means
  2. Opportunity cost is the whole calculation
  3. Worked example: oil and corn, measured in hours
  4. The same math with output per worker
  5. Gains from trade, in bushels and cars
  6. Absolute advantage is a different test
  7. The trade price has to sit between the two costs
  8. What the calculator returns

What comparative advantage means

Comparative advantage is about what a producer gives up, not what it can make. A country, company, or worker has a comparative advantage in a good when its opportunity cost for that good is lower than anyone else's. David Ricardo set out the idea in 1817 in On the Principles of Political Economy and Taxation, using two countries and two goods to show that trade can help both sides even when one side is better at everything.

OpenStax Principles of Economics 2e, section 33.1 states the test plainly: the question each country should ask is what it gives up to produce the good. The answer is a ratio, and the smaller ratio wins. This calculator computes that ratio for both producers and both goods, then reports who should make what.

Opportunity cost is the whole calculation

Production data come in two shapes, and the arithmetic differs between them.

If you know output per worker, the opportunity cost of one unit of good X is the output of good Y divided by the output of good X. A worker who can make 6 cars or 12 tons of wheat gives up 12 tons of wheat to make 6 cars, so one car costs 2 tons of wheat.

If you know hours per unit, the opportunity cost of one unit of good X is the hours needed for X divided by the hours needed for Y. A barrel of oil that takes 1 hour, in a country where a bushel of corn takes 4 hours, costs a quarter of a bushel.

The two directions are reciprocals. If one car costs 2 tons of wheat, one ton of wheat costs half a car, and 2 times 0.5 equals 1. Run that check on your own numbers, because it catches most data entry errors.

Worked example: oil and corn, measured in hours

OpenStax's numerical example uses Saudi Arabia and the United States, oil and corn, with hours per unit as the input. Saudi Arabia needs 1 hour per barrel of oil and 4 hours per bushel of corn. The United States needs 2 hours per barrel and 1 hour per bushel.

Give Saudi Arabia 100 hours of labor and it can produce 100 barrels of oil or 25 bushels of corn, so one barrel costs a quarter of a bushel. Give the United States the same 100 hours and it can produce 50 barrels or 100 bushels, so one barrel costs 2 bushels.

CountryHours per barrel of oilHours per bushel of corn
Saudi Arabia14
United States21
CountryCost of 1 barrel, in bushelsCost of 1 bushel, in barrels
Saudi Arabia0.254
United States20.5

Saudi Arabia holds the comparative advantage in oil, at a quarter bushel per barrel against 2. The United States holds it in corn, at half a barrel per bushel against 4. Each side is the low-cost producer of exactly one good, so each has something to trade.

The same math with output per worker

Output data work the same way with the ratio flipped. Suppose a United States worker can produce 12 tons of wheat or 6 cars in a year, and a Brazilian worker can produce 8 tons of wheat or 2 cars.

For the United States, one car costs 12 divided by 6, which is 2 tons of wheat. For Brazil, one car costs 8 divided by 2, which is 4 tons. Read the other direction and Brazil gives up less to make wheat: 2 divided by 8 is 0.25 car per ton, against 6 divided by 12, or 0.5 car per ton, for the United States.

ProducerWheat, tons per yearCars per year
United States126
Brazil82

Brazil holds the comparative advantage in wheat even though the United States outproduces it in both goods. That result is the part people find hardest to accept, and it is the core of Ricardo's argument.

Gains from trade, in bushels and cars

Pick a trade price inside the two opportunity costs, say 1 car for 3 tons of wheat. It sits between 2 and 4, so both sides gain.

Before trade, suppose the United States splits its worker between the goods at 4 tons of wheat and 4 cars, which uses exactly one worker's capacity. Brazil splits at 4 tons of wheat and 1 car, also using its full capacity.

After trade, the United States puts the whole worker into cars, makes 6, and swaps 1 car for 3 tons of wheat. Brazil puts the whole worker into wheat, makes 8 tons, and swaps 3 tons for 1 car.

CountryBefore tradeAfter tradeChange
United States4 wheat, 4 cars3 wheat, 5 cars1 more car, 1 less wheat
Brazil4 wheat, 1 car5 wheat, 1 car1 more wheat

Value each bundle at the trade price of 3 tons per car. The United States moves from 4 plus 12, or 16 tons, to 3 plus 15, or 18 tons, a gain of 2. Brazil moves from 4 plus 3, or 7 tons, to 5 plus 3, or 8 tons, a gain of 1. Nobody loses, and world output rises from 8 tons of wheat and 5 cars to 8 tons and 6 cars, because each worker now produces only the good with the lower cost.

Absolute advantage is a different test

Absolute advantage compares raw productivity, with no ratio involved. In the wheat and car case the United States has it in both goods: 12 tons against 8, and 6 cars against 2. That fact does not block trade, because comparative advantage looks at the trade-off, not the level.

The same chapter appears in OpenStax Principles of Macroeconomics 3e, section 20.1, with the same oil and corn numbers for anyone who wants a second telling of the example.

In the oil and corn case each country holds one absolute advantage. Saudi Arabia needs 1 hour per barrel against 2, and the United States needs 1 hour per bushel against 4. There the absolute and comparative verdicts line up, which is common but not guaranteed. The wheat and car case shows why the two tests must be kept apart.

The trade price has to sit between the two costs

A trade price outside the two opportunity costs cannot satisfy both sides. For cars and wheat the workable range is 2 to 4 tons per car. At exactly 2 the United States gains nothing, because that is its own cost. At exactly 4 Brazil gains nothing. Any price strictly inside the range leaves room for both.

In the oil case the range is 0.25 to 2 bushels per barrel. A price of 1 bushel per barrel would suit Saudi Arabia, which normally gives up only a quarter bushel to make a barrel at home, and it would suit the United States, which normally pays 2 bushels for the same barrel. Both sides buy cheap relative to their own cost of production.

Real trade also carries shipping, tariffs, and exchange rates, none of which this calculator models. Treat the range as the boundary condition, then adjust for those costs on top. When you want to see the real trade flows behind the model, the Census Bureau's foreign trade data pages publish the annual figures by country and product.

What the calculator returns

The defaults are the OpenStax oil and corn figures in hours per unit: 1 and 4 for country A, 2 and 1 for country B. The tool returns four opportunity costs, two verdicts, and the terms-of-trade range.

OutputValue for the default case
Cost of 1 barrel of oil, country A0.25 bushels
Cost of 1 barrel of oil, country B2 bushels
Cost of 1 bushel of corn, country A4 barrels
Cost of 1 bushel of corn, country B0.5 barrels
Comparative advantage in oilCountry A, at 0.25 against 2
Comparative advantage in cornCountry B, at 0.5 against 4
Workable trade price for 1 barrel0.25 to 2 bushels

Switch the input type to output per worker and the same four numbers are read the other way round. That is the setting for production tables that report units per worker or per day, like the wheat and car case above.

Frequently asked questions

What is comparative advantage?

It is the ability to produce a good at a lower opportunity cost than another producer. Saudi Arabia gives up 0.25 bushels of corn per barrel of oil while the United States gives up 2, so Saudi Arabia has the comparative advantage in oil.

How do you calculate opportunity cost?

With output data, divide the other good's output by this good's output: 12 divided by 6 gives 2 tons of wheat per car. With hours per unit, divide the hours for this good by the hours for the other good: 2 divided by 1 gives 2 bushels per barrel.

What is the difference between absolute and comparative advantage?

Absolute advantage compares raw output. The United States produces 12 tons of wheat against Brazil's 8 and 6 cars against 2, so it has the absolute advantage in both. Comparative advantage compares trade-offs, and Brazil still holds it in wheat.

Who has the comparative advantage in oil in the OpenStax example?

Saudi Arabia. One barrel costs it 0.25 bushels of corn, while the same barrel costs the United States 2 bushels.

What is a good terms of trade?

Any price between the two opportunity costs. For cars and wheat the range is 2 to 4 tons per car, and a price of 3 tons per car gives both sides a gain.

Can one country have a comparative advantage in both goods?

Not with two goods and constant costs. The two opportunity costs are reciprocals, so if one country is lower in one direction it must be higher in the other. Equal costs on both sides are the tie case.

What happens if the opportunity costs are equal?

There is nothing to gain from trade. If one car costs 2 tons of wheat in both countries, neither side can offer a price the other cannot match at home.

How do I use hours per unit instead of output?

Switch the input type to hours per unit and enter the hours for each good. The calculator then divides hours for X by hours for Y, which turns 1 hour per barrel and 4 hours per bushel into 0.25 bushels per barrel.

Does trade make one country worse off?

Not in this model. Brazil ends with 5 tons of wheat and 1 car after trade, against 4 tons and 1 car before, and the United States gains 2 tons of wheat at the trade price. Both bundles improve.

What was Ricardo's own example?

England and Portugal trading cloth and wine, set out in 1817 in On the Principles of Political Economy and Taxation. The two-good structure this calculator uses is the same one Ricardo drew.

Why trade if one country is better at everything?

Because its advantage is bigger in one good than the other. The United States is twice as good at wheat and three times as good at cars in the output example, so it should lean into cars and buy wheat.

What is the opportunity cost of 1 bushel of corn for the United States?

Half a barrel of oil. Corn takes 1 hour and oil takes 2, so 1 divided by 2 is 0.5 barrels per bushel.

Does the calculator include tariffs or shipping costs?

No. It computes opportunity costs and the trade price range from production data alone, which is the textbook model. Real trade costs sit on top of that range.

Spotted a wrong number or a broken result?

More Finance tools

See all Finance tools

Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.