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.
| Comparative advantage in good X | |
| Comparative advantage in good Y | |
| Opportunity cost of 1 X, country A | |
| Opportunity cost of 1 X, country B | |
| Opportunity cost of 1 Y, country A | |
| Opportunity cost of 1 Y, country B | |
| Workable trade price for 1 X | |
| Absolute advantage | |
Enter hours per unit or output per worker for two producers and two goods. The lower opportunity cost wins that good. All calculations run in your browser and no data is uploaded.
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.
Key takeaways
- Comparative advantage goes to the producer with the lower opportunity cost, not the higher output
- In the OpenStax example Saudi Arabia pays 0.25 bushels of corn per barrel of oil and the United States pays 2
- Opportunity costs in the two directions are reciprocals: 2 times 0.5 equals 1
- A trade price of 1 car for 3 tons of wheat benefits both sides when the costs are 2 and 4
- The United States outproduces Brazil in wheat and cars, yet both countries still gain from trading
On this page
- What comparative advantage means
- Opportunity cost is the whole calculation
- Worked example: oil and corn, measured in hours
- The same math with output per worker
- Gains from trade, in bushels and cars
- Absolute advantage is a different test
- The trade price has to sit between the two costs
- 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.
| Country | Hours per barrel of oil | Hours per bushel of corn |
|---|---|---|
| Saudi Arabia | 1 | 4 |
| United States | 2 | 1 |
| Country | Cost of 1 barrel, in bushels | Cost of 1 bushel, in barrels |
|---|---|---|
| Saudi Arabia | 0.25 | 4 |
| United States | 2 | 0.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.
| Producer | Wheat, tons per year | Cars per year |
|---|---|---|
| United States | 12 | 6 |
| Brazil | 8 | 2 |
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.
| Country | Before trade | After trade | Change |
|---|---|---|---|
| United States | 4 wheat, 4 cars | 3 wheat, 5 cars | 1 more car, 1 less wheat |
| Brazil | 4 wheat, 1 car | 5 wheat, 1 car | 1 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.
| Output | Value for the default case |
|---|---|
| Cost of 1 barrel of oil, country A | 0.25 bushels |
| Cost of 1 barrel of oil, country B | 2 bushels |
| Cost of 1 bushel of corn, country A | 4 barrels |
| Cost of 1 bushel of corn, country B | 0.5 barrels |
| Comparative advantage in oil | Country A, at 0.25 against 2 |
| Comparative advantage in corn | Country B, at 0.5 against 4 |
| Workable trade price for 1 barrel | 0.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
- $100,000 Loan for 15 Years Calculator
- $15 an Hour Is How Much a Year?
- $15,000 Loan Over 5 Years Calculator
- $20 an Hour Is How Much a Year?
- $25 an Hour Is How Much a Year?
- $30 an Hour Is How Much a Year?
- 1 Year CD Rate Calculator
- 10 Year ARM Mortgage Calculator
- 10 Year Equipment Loan Calculator
- 10-Year Balloon Mortgage Calculator
- 10-Year Fixed Loan Calculator
- 10-Year Fixed Mortgage Calculator
- 10-Year Fixed Mortgage Rates Calculator
- 10-Year Second Mortgage Calculator
- 10/1 ARM vs 30 Year Fixed Calculator
- 1099 vs W-2 Calculator
Fee schedules, rates and rules change without notice. Always confirm important figures with the official source before you rely on them.