One company runs the only ferry to an island, so it is a monopoly: it chooses how many tickets to sell, and the price is whatever the passengers will pay for that many. Each day, selling Q tickets (any Q >= 0, not only whole numbers) fetches the price given by the inverse demand curve
dollars per ticket. Running the ferry for Q passengers costs
dollars a day, so the marginal cost is MC(Q) = c + 2d\,Q. Revenue is R(Q) = P(Q) \cdot Q = a\,Q - b\,Q^2, and marginal revenue, the extra revenue from one more ticket when the price of all the others must fall too, is MR(Q) = a - 2b\,Q.
The ferry chooses the Q where MR(Q) = MC(Q). The fixed cost is already committed (the boat is bought), so the ferry runs at that Q even if its profit is negative.
Write ferry(a, b, c, d, fixed) that returns a tuple (Q, P, profit): the number of tickets, the ticket price, and the daily profit P \cdot Q - C(Q).
Examples
Input: a = 60, b = 0.5, c = 12, d = 0.1, fixed = 500
Output: (40.0, 40.0, 460.0)
Explanation: MR = 60 - Q and MC = 12 + 0.2 Q meet at Q = 40. Passengers pay 60 - 20 = 40.
Revenue 1600 minus cost 500 + 480 + 160 = 1140 leaves 460.
Input: a = 30, b = 1, c = 6, d = 0, fixed = 200
Output: (12.0, 18.0, -56.0)
Explanation: 12 tickets at 18 earn 144 above the 72 of fuel, not enough for the 200 fixed cost.
Constraints
- answers are compared with a tolerance of
1e-6
Goals
- Write marginal revenue for a linear inverse demand curve
- Set marginal revenue equal to marginal cost and solve for the quantity
- Read the price off the demand curve, not off the cost curve