A town has firms identical small bakeries, all price takers in the market for sourdough. A bakery that bakes q dozen loaves a day (any q >= 0, not only whole numbers) has the variable cost
dollars, plus a fixed cost that does not depend on q and does not matter here. Its marginal cost is the slope of that cost, MC(q) = a - 2b\,q + 3c\,q^2, and its average variable cost is AVC(q) = VC(q) / q = a - b\,q + c\,q^2. Both curves are U-shaped.
At a market price P (dollars per dozen) each bakery chooses its output by this rule:
- if
Pis below the lowest value of AVC (the shutdown price), it bakes nothing,q = 0; - otherwise it bakes the
qwhere P = MC(q) on the rising part of the marginal cost curve (the larger of the two solutions). At a price exactly equal to the shutdown price it bakes that output too.
The market supply at price P is the total of all bakeries' outputs.
Write market_supply(a, b, c, firms, prices) that returns a tuple (shutdown, supply): the shutdown price, and the list of market supplies, one for each price in prices, in the same order. Press Run with plot(supply, prices) (quantity across, price up, as economists draw it) to see the supply curve and its jump at the shutdown price.
Examples
Input: a = 10, b = 2, c = 0.5, firms = 100, prices = [6, 8, 11.5, 18]
Output: (8.0, [0, 200.0, 300.0, 400.0])
Explanation: AVC(q) = 10 - 2q + 0.5q^2 is lowest at q = 2, where it is 8.
At P = 8 each bakery bakes 2 dozen; MC(3) = 11.5 and MC(4) = 18.
Input: a = 3, b = 0, c = 1, firms = 1, prices = [2, 3, 15]
Output: (3.0, [0, 0.0, 2.0])
Explanation: with b = 0 both curves rise from q = 0, and MC(2) = 3 + 12 = 15.
Constraints
- answers are compared with a tolerance of
1e-6
Goals
- Solve price = marginal cost for the output on the rising part of the marginal cost curve
- Apply the shutdown rule from the minimum of average variable cost
- Add up identical firms' supplies into a market supply curve