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.
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
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
TG we-Calculate Editorial Team. (2026). Comparative Advantage Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/comparative-advantage-calculator
TG we-Calculate Editorial Team. "Comparative Advantage Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/comparative-advantage-calculator.
TG we-Calculate Editorial Team, "Comparative Advantage Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/comparative-advantage-calculator
@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?
