Intermediate

Comparative Advantage Calculator

Enter the maximum output of two goods for two countries, and instantly see who holds the comparative advantage in each, the opportunity costs, and the range of prices at which trade benefits both sides.
Units of Good X if A specialises entirely in X
Units of Good Y if A specialises entirely in Y
Units of Good X if B specialises entirely in X
Units of Good Y if B specialises entirely in Y
Comparative advantage in Good X
Country A
Comparative advantage in Good Y
Country B
A opp. cost of X (in Y)
0.6
B opp. cost of X (in Y)
1
A opp. cost of Y (in X)
1.667
B opp. cost of Y (in X)
1
Absolute adv. in X
Country A
Absolute adv. in Y
Country B
Mutually beneficial trade range (X for Y)
0.6 – 1 Y per X
Lock the current result, then change any input to compare scenarios.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. This is not financial, investment or tax advice; consult a qualified professional. Read the full disclaimer.
Quick answer

How does this calculator work?

Opportunity cost of X for A = max_Y_A ÷ max_X_A. Whichever country has the lower opportunity cost of X has the comparative advantage in X. Both countries gain when they specialise and trade at a price between their two opportunity costs. This follows Ricardo's 1817 model assuming constant returns and a single factor of production.

Formula
OC of X for A = (max Y for A) ÷ (max X for A) · Comparative advantage in X goes to whoever has the lower opportunity cost of X.
How this is calculated

Comparative advantage, first formalised by David Ricardo in 1817, rests on opportunity cost rather than raw output. Even if one country can produce more of everything (absolute advantage), both countries gain from trade if each specialises in the good for which it gives up the least of the other good.

The opportunity cost of producing one unit of Good X for Country A is the number of units of Good Y it must forgo: OC(X|A) = max_Y_A ÷ max_X_A. Whoever has the lower opportunity cost of X has the comparative advantage in X; the other automatically holds the comparative advantage in Y (opportunity costs are reciprocals). When opportunity costs are identical, neither party gains from specialisation.

The mutually beneficial terms of trade lie between the two opportunity costs. A trade price for X outside that range would leave one party worse off than self-sufficiency. The Production Possibility Frontier (PPF) lines on the chart show each country's full output trade-off; the party with the steeper PPF slope for X holds the comparative advantage in X.

Frequently asked questions

Enter the maximum quantity of Good X each country can produce if it devotes all resources to X, and the maximum of Good Y if all resources go to Y. These define the endpoints of each Production Possibility Frontier.

No. By construction, if A's opportunity cost of X is lower than B's, then B's opportunity cost of Y must be lower than A's. A single party can hold absolute advantage in both goods, but comparative advantage always splits between them (unless opportunity costs are exactly equal).

The two lines are the Production Possibility Frontiers — each traces all combinations of Good X and Good Y a country can produce with full resource use. The steeper line produces relatively more Y per unit of X, which means producing X costs more Y — so the steeper-line country specialises in Y.

Also known as

comparative advantage economics
opportunity cost trade calculator
production possibility frontier calculator
ricardian comparative advantage
who has comparative advantage
specialisation and trade economics
absolute advantage vs comparative advantage
terms of trade calculator

APA

TG we-Calculate Editorial Team. (2026). Comparative Advantage Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/comparative-advantage-calculator

Chicago

TG we-Calculate Editorial Team. "Comparative Advantage Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/comparative-advantage-calculator.

IEEE

TG we-Calculate Editorial Team, "Comparative Advantage Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/comparative-advantage-calculator

BibTeX

@misc{wecalculate_comparative_advantage_calculator, title = {Comparative Advantage Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/comparative-advantage-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?