Comparative Advantage Simulator
A two-country, two-good Ricardian model. Set how productive each country is, watch specialisation and trade move the world to a more efficient allocation. The simulator that David Ricardo would have built in 1817 if he had a laptop.
Two countries. Two goods. Even when one country is better at making both, specialisation and trade leave both with more than they could make alone. Drag the inputs to see Ricardo's maths play out.
Country A
Country B
Pre-trade allocation (no specialisation yet)
Drag the sliders to set how each country splits its labour without trade. Move them around to see how much output is lost relative to the specialised case.
World Cloth after specialising
240.0
Cloth pre-trade
253.3
Wine specialised
300.0
Wine pre-trade
250.0
Comparative advantage
England should specialise in Cloth, Portugal in Wine
Opportunity cost is what each side gives up to make a unit of the other good. England sacrifices 0.83 Wine per Cloth; Portugal sacrifices 1.13. Whoever sacrifices less has comparative advantage in that good.
Opportunity costs
How many units of one good a country gives up to make one unit of the other. The country with the lower opportunity cost in a good is the one with comparative advantage in it.
| Country | Cost of 1 Cloth (in Wine) | Cost of 1 Wine (in Cloth) |
|---|---|---|
| England | 0.833 | 1.200 |
| Portugal | 1.125 | 0.889 |
Pre-trade vs full specialisation
World output before and after each country fully specialises in the good it has comparative advantage in. Blue is the specialised number; grey is what you produced without trade.
-13.3 units (-5.3%)
+50.0 units (+20.0%)
Specialisation can produce less of one good and much more of the other. The Ricardian insight is that any combination on the joint frontier can be redistributed via trade so both countries consume more of both goods than they could in autarky. The simulator shows production; the gains for individual households come from the exchange that follows.
Why this matters
David Ricardo's 1817 argument was that even when one country is worse at producing every good than another, both countries still gain from trade. The reason is opportunity cost. The country that is bad at everything is least bad at something, and the country that is good at everything has to give up a lot of the high-value good to make the low-value one.
In the default example, Portugal can make both cloth and wine with fewer hours than England. The classical answer would be that Portugal should produce both and England should produce nothing. Ricardo's answer is the opposite: Portugal should pour everything into wine (where it is dramatically more efficient) and let England produce cloth (where its disadvantage is smallest). Both countries end up with more wine and cloth than they would have alone.
The same logic applies to two people, two firms, or two regions of the same country. Specialisation and trade is one of the few results in economics that is both mathematically tight and politically contentious.
The complete guide
Comparative Advantage Simulator: Ricardo Explained with Sliders
Free interactive comparative advantage simulator. See how Ricardo's 1817 two-country, two-good model produces gains from trade, plus the limits the textbooks skip.
Comparative advantage is the most powerful idea in economics that almost nobody outside the discipline understands properly. Our comparative advantage simulator lets you drag the inputs of David Ricardo's 1817 two-country, two-good model and watch the gains from trade fall out of the maths in real time.
Contents
- What Comparative Advantage Actually Means
- How to Use the Simulator
- A Worked Example: Ricardo's England and Portugal
- Modern Applications: Services, Brexit, and AI
- What the Model Does Not Say
What Comparative Advantage Actually Means
Absolute advantage is the obvious one. If you can make a shirt in two hours and your neighbour takes four, you have absolute advantage in shirts. The intuitive conclusion is that you should make the shirts and they should not. That intuition is wrong as soon as both of you also have other things to do.
Comparative advantage is about opportunity cost: what each side gives up to produce a unit of something. Ricardo's insight, set out in chapter 7 of On the Principles of Political Economy and Taxation in 1817, was that the right question is not "who is faster" but "who gives up less". Even if Portugal makes both cloth and wine with fewer hours than England, Portugal gives up a great deal of wine to make a unit of cloth. England gives up much less wine per unit of cloth, because its wine production is so weak that the foregone wine is not worth much. England therefore has comparative advantage in cloth despite being absolutely worse at everything.
The reason this matters is that the result generalises. Two people, two firms, two regions, two countries: any time two parties are dividing finite time across multiple activities, both can gain by specialising in their lowest-opportunity-cost activity and trading for the rest. Ricardo proved it with arithmetic, not rhetoric, and the proof has survived two hundred years of attempts to knock it down. The politics around it are another matter, which is where the simulator earns its keep: it separates the maths from the policy and lets you poke each one.
How to Use the Simulator
The interface mirrors Ricardo's original setup: two countries, two goods, labour hours as the only input.
Name the countries and goods
Default to England, Portugal, Cloth, and Wine if you want to follow the textbook. Swap them out for anything you like - the maths is identical whether you are simulating UK and Germany trading cars and financial services, or a doctor and a gardener swapping medical advice for lawn mowing.
Set hours per unit for each country
For each country, enter how many labour hours it takes to produce one unit of each good. Lower is more productive. If Country A takes 100 hours to make a unit of cloth and Country B takes 90, B is absolutely more productive at cloth. Whether B also has comparative advantage in cloth depends on what each gives up in wine to produce that cloth.
Set total labour hours
This is the budget. A country with 24,000 hours can make many wines, much cloth, or any mix on its production frontier. The total scales the output bars but not the comparative-advantage conclusion - that comes from the ratio of hours, not the absolute number.
Drag the pre-trade allocation sliders
The sliders set how each country splits its labour without trade. Move them around and watch the grey "pre-trade" bars shift. Then compare with the blue "specialised" bars, which assume each country pours everything into the good it has comparative advantage in. The gap between the two is the gains from trade.
Use the presets to jump in
Three presets cover the canonical examples: Ricardo's original England-Portugal, a modern UK-Germany services-versus-cars setup, and a doctor-gardener personal-finance version. Click through all three to see the same maths apply at country, firm, and household scale.
A Worked Example: Ricardo's England and Portugal
Load the Ricardo's England vs Portugal preset. The numbers are:
- England: 100 hours per cloth, 120 hours per wine, 24,000 total hours
- Portugal: 90 hours per cloth, 80 hours per wine, 24,000 total hours
Portugal is absolutely more productive at both goods. The classical pre-Ricardo view would have been that Portugal should make everything. Ricardo's argument starts with opportunity cost.
In England, a unit of wine costs 120/100 = 1.2 units of cloth in foregone production. In Portugal, a unit of wine costs 80/90 = 0.89 units of cloth. Portugal sacrifices less cloth per wine than England does, so Portugal has comparative advantage in wine. Run it the other way: in England a unit of cloth costs 100/120 = 0.83 units of wine; in Portugal it costs 90/80 = 1.125 units of wine. England sacrifices less wine per cloth, so England has comparative advantage in cloth.
Pull the sliders to a 50/50 split in both countries (no specialisation). Pre-trade world output is roughly 120 units of cloth and 180 units of wine. Now click the verdict's recommended split - Portugal fully on wine, England fully on cloth. World cloth jumps to 240 units; world wine to 300 units. Both goods go up. That is the gains-from-trade number that the model is famous for. Move England's hours per cloth from 100 to 150 and watch the gap shrink. Push it to 200 and the gap stays positive but smaller. The result that gains from trade exist is robust to a remarkable range of parameter choices, which is part of why economists treat it as close to a theorem.
Modern Applications: Services, Brexit, and AI
The Ricardian frame is the spine of every serious argument for open trade. The simulator's UK vs Germany preset captures one current example: the UK has comparative advantage in financial services, Germany in cars. Under that allocation both countries are better off than if each tried to do both, which is the textbook free-trade case. Brexit ran into this directly. Leaving the EU's single market raised the friction on financial-services exports and on the import of car components in ways that Ricardo's model predicts will lower aggregate UK output, and which the Office for Budget Responsibility's analysis broadly confirms. That is the model in action whether you liked the political result or not. Worth pairing with our piece on why the UK won't tax wealth for the wider picture of how political constraints sit on top of economic models.
The hottest current application is AI. "AI is better than humans at X" is an absolute-advantage statement. Comparative advantage guarantees that as long as AI is relatively even more productive at something else than at X, humans retain comparative advantage in X by definition. That is reassuring at the aggregate level. What it does not promise is that the work humans should still do pays well, exists where you live, or sits in the industry you have spent twenty years building skills in. The aggregate answer is reassuring. The distributional answer is not, which is the boomers-had-it-easier problem in a different form.
For personal-finance scale, the Doctor vs gardener preset is the most useful. Even if you are faster than every cleaner, accountant, and gardener you might hire, your time is worth more doing what you are relatively best at. Outsourcing the rest is comparative advantage in action. Same maths, household scale.
What the Model Does Not Say
Ricardo proved that both countries gain on net. He did not prove that every worker within each country gains. That distinction is the single most abused result in economics.
When the model says specialisation raises combined output, it averages across all citizens. In practice, the gains accrue to consumers and to workers in the expanding industry. The losses fall on workers in the shrinking industry, who are often older, geographically concentrated, and skilled in the wrong thing to easily move into the expanding sector. The English textile workers displaced by 19th-century industrialisation, the American steelworkers hollowed out by NAFTA, the manufacturing communities of northern England under post-1980s trade liberalisation: these are not rounding errors. They are real people whose labour-market position got destroyed in pursuit of an aggregate gain that landed somewhere else.
The honest reading is that comparative advantage is excellent for personal decisions and weak as a sole basis for trade policy. If you are deciding whether to mow your own lawn or hire a gardener, Ricardo is your friend. If you are deciding whether to liberalise an entire industry, Ricardo is one input among several, and any policy that does not pair the trade deal with retraining, transition support, and redistribution that actually reaches the displaced workers is using the model dishonestly. The aggregate case for trade is strong. The political case requires more than the model alone provides, which is why every textbook chapter that ends with "and therefore free trade is good" is doing the reader a quiet disservice.
If you want to size the financial buffer you'd need to survive an industry being hollowed out by the next trade deal or the next AI breakthrough, our FI number calculator gives you the headline figure. Comparative advantage tells you the world will keep producing. It does not tell you it will keep producing a wage for you.
Frequently asked questions
What is comparative advantage in simple terms?
How is comparative advantage different from absolute advantage?
Why does Ricardo say Portugal should not make both goods?
How does comparative advantage apply to personal finance?
Does comparative advantage mean free trade is always good?
What does comparative advantage say about AI taking jobs?
Is comparative advantage still relevant in the 21st century?
Does comparative advantage favour rich countries?
How does comparative advantage apply to services?
Can a country lose comparative advantage in everything?
Why do economists keep teaching this model if its policy implications are contested?
Important: Not Financial Advice
This calculator is provided for educational and illustrative purposes only. Freedom Isn't Free is not authorised or regulated by the Financial Conduct Authority (FCA) and does not provide financial advice, investment recommendations, or tax guidance.
The projections shown are hypothetical, assume a constant rate of return, and do not account for inflation, taxes, or fees. Actual investment returns vary and you may get back less than you invest. Past performance is not a reliable indicator of future results.
Before making any financial decisions, please consult with an independent financial adviser regulated by the FCA. For help finding an adviser, visit MoneyHelper or Unbiased.
Where links to financial products appear on this page, some may be affiliate links. See our full disclaimer for details.
Something not right? Contact us
Enjoying the content?
If this site has been useful, a coffee goes a long way.