The comparative advantage formula involves calculating the opportunity cost of producing one unit of a good in terms of the alternative good forgone. It's expressed as: Opportunity Cost of Good A = (Units of Good B given up) / (Units of Good A gained)