Two hikers, A and B, share the supplies for a long trail: X bags of nuts (good 1) and Y bags of dried fruit (good 2). Any split can be drawn as a point in an Edgeworth box: if A takes (x, y), B takes the rest, (X - x, Y - y).
Their tastes are Cobb-Douglas: u_A = x^{a} y^{1-a} and u_B = x_B^{b} y_B^{1-b} for B's bundle (x_B, y_B). A person's marginal rate of substitution (MRS) is how much fruit they would give up for a tiny extra amount of nuts; for u = x^a y^{1-a} it is
A split is Pareto efficient if no other split makes one hiker better off without making the other worse off. Strictly inside the box (both hikers have some of each good) that happens exactly when the two MRS are equal. If A's MRS is larger, A values nuts more than B does, so moving a little nuts from B to A, paid for with fruit at a rate between the two MRS, helps both: A should buy good 1. If B's MRS is larger, B should.
Write edgeworth_check(a, b, totals, splits, n) that returns a tuple (verdicts, curve):
verdicts: for each of A's bundles(x, y)insplits, the string"efficient"if |\text{MRS}_A - \text{MRS}_B| \le 10^{-9} \cdot \max(\text{MRS}_A, \text{MRS}_B), otherwise"A buys good 1"or"B buys good 1";curve: the contract curve (all efficient splits) at the nut amounts x_k = k X / n for k = 1, \dots, n - 1: a list of A's bundles (x_k, y_k), where y_k is the fruit that makes the split efficient.
Examples
Input: a = 0.8, b = 0.5, totals = (10, 30), splits = [(5, 6), (5, 15), (8, 3)], n = 5
Output: (['efficient', 'A buys good 1', 'B buys good 1'],
[(2.0, 1.76470588), (4.0, 4.28571429), (6.0, 8.18181818), (8.0, 15.0)])
Explanation: at (5, 6) A's MRS is 4 * 6 / 5 = 4.8 and B's is 1 * 24 / 5 = 4.8.
At (5, 15) they are 12 and 3: A values nuts far more. At (8, 3): 1.5 against 13.5.
Input: a = 0.5, b = 0.5, totals = (4, 8), splits = [(1, 2), (3, 6.000001)], n = 4
Output: (['efficient', 'A buys good 1'], [(1.0, 2.0), (2.0, 4.0), (3.0, 6.0)])
Explanation: with the same tastes the contract curve is the diagonal of the box; a
millionth of a bag off it is already inefficient.
Constraints
- every split is strictly inside the box:
0 < x < Xand0 < y < Y - the points of
curveare compared with a relative tolerance of1e-6
Goals
- Compute each person's marginal rate of substitution at a split of two goods
- Classify a split as efficient, or say who should get more of good 1 in a trade that helps both
- Derive the contract curve by solving the equal-MRS condition for good 2