|
186 | 186 | "# Both should equal free market equilibrium\n", |
187 | 187 | "print(f\"Free market: P = ${free_market.p:.2f}, Q = {free_market.q:.0f}\")" |
188 | 188 | ] |
189 | | - }, |
190 | | - { |
191 | | - "cell_type": "markdown", |
192 | | - "id": "welfare", |
193 | | - "metadata": {}, |
194 | | - "source": [ |
195 | | - "## Welfare Analysis\n", |
196 | | - "\n", |
197 | | - "Price controls reduce total surplus by preventing some mutually beneficial trades:" |
198 | | - ] |
199 | | - }, |
200 | | - { |
201 | | - "cell_type": "code", |
202 | | - "execution_count": null, |
203 | | - "id": "welfare-comparison", |
204 | | - "metadata": {}, |
205 | | - "outputs": [], |
206 | | - "source": [ |
207 | | - "# Compare welfare across different scenarios\n", |
208 | | - "scenarios = [\n", |
209 | | - " (\"Free Market\", free_market),\n", |
210 | | - " (\"Price Ceiling ($8)\", ceiling_market),\n", |
211 | | - " (\"Price Floor ($12)\", floor_market)\n", |
212 | | - "]\n", |
213 | | - "\n", |
214 | | - "print(\"Welfare Comparison:\")\n", |
215 | | - "print(\"-\" * 50)\n", |
216 | | - "for name, market in scenarios:\n", |
217 | | - " print(f\"{name:20} CS: ${market.consumer_surplus:6.2f} \"\n", |
218 | | - " f\"PS: ${market.producer_surplus:6.2f} \"\n", |
219 | | - " f\"Total: ${market.total_surplus:6.2f}\")\n", |
220 | | - "print(\"-\" * 50)\n", |
221 | | - "print(f\"DWL from ceiling: ${ceiling_market.dwl:.2f}\")\n", |
222 | | - "print(f\"DWL from floor: ${floor_market.dwl:.2f}\")" |
223 | | - ] |
224 | | - }, |
225 | | - { |
226 | | - "cell_type": "markdown", |
227 | | - "id": "elasticity-impact", |
228 | | - "metadata": {}, |
229 | | - "source": [ |
230 | | - "## Elasticity and Price Controls\n", |
231 | | - "\n", |
232 | | - "The impact of price controls depends on the elasticity of supply and demand. Let's compare markets with different elasticities:" |
233 | | - ] |
234 | | - }, |
235 | | - { |
236 | | - "cell_type": "code", |
237 | | - "execution_count": null, |
238 | | - "id": "elasticity-comparison", |
239 | | - "metadata": {}, |
240 | | - "outputs": [], |
241 | | - "source": [ |
242 | | - "# More elastic demand (flatter)\n", |
243 | | - "elastic_demand = Demand.from_formula(\"P = 20 - 0.5*Q\")\n", |
244 | | - "elastic_market = Market(elastic_demand, supply)\n", |
245 | | - "elastic_ceiling = Market(elastic_demand, supply, ceiling=8)\n", |
246 | | - "\n", |
247 | | - "# Compare shortages\n", |
248 | | - "inelastic_shortage = demand.q(8) - supply.q(8)\n", |
249 | | - "elastic_shortage = elastic_demand.q(8) - supply.q(8)\n", |
250 | | - "\n", |
251 | | - "print(\"Effect of $8 ceiling with different demand elasticities:\")\n", |
252 | | - "print(f\" Inelastic demand shortage: {inelastic_shortage:.0f} units\")\n", |
253 | | - "print(f\" Elastic demand shortage: {elastic_shortage:.0f} units\")\n", |
254 | | - "print(f\" Inelastic DWL: ${ceiling_market.dwl:.2f}\")\n", |
255 | | - "print(f\" Elastic DWL: ${elastic_ceiling.dwl:.2f}\")" |
256 | | - ] |
257 | | - }, |
258 | | - { |
259 | | - "cell_type": "markdown", |
260 | | - "id": "visual-comparison", |
261 | | - "metadata": {}, |
262 | | - "source": [ |
263 | | - "## Visual Comparison\n", |
264 | | - "\n", |
265 | | - "Let's create a side-by-side comparison of price ceiling and floor effects:" |
266 | | - ] |
267 | | - }, |
268 | | - { |
269 | | - "cell_type": "code", |
270 | | - "execution_count": null, |
271 | | - "id": "side-by-side", |
272 | | - "metadata": {}, |
273 | | - "outputs": [], |
274 | | - "source": [ |
275 | | - "import matplotlib.pyplot as plt\n", |
276 | | - "\n", |
277 | | - "fig, (ax1, ax2) = plt.subplots(1, 2, figsize=(12, 5))\n", |
278 | | - "\n", |
279 | | - "# Price ceiling plot\n", |
280 | | - "ceiling_market.plot(ax=ax1, surplus=True)\n", |
281 | | - "ax1.set_title(\"Price Ceiling at $8\\n(Creates Shortage)\")\n", |
282 | | - "ax1.axhline(8, color='red', linestyle='--', alpha=0.7, label='Ceiling')\n", |
283 | | - "ax1.legend()\n", |
284 | | - "\n", |
285 | | - "# Price floor plot\n", |
286 | | - "floor_market.plot(ax=ax2, surplus=True)\n", |
287 | | - "ax2.set_title(\"Price Floor at $12\\n(Creates Surplus)\")\n", |
288 | | - "ax2.axhline(12, color='red', linestyle='--', alpha=0.7, label='Floor')\n", |
289 | | - "ax2.legend()\n", |
290 | | - "\n", |
291 | | - "plt.tight_layout()\n", |
292 | | - "plt.show()" |
293 | | - ] |
294 | | - }, |
295 | | - { |
296 | | - "cell_type": "markdown", |
297 | | - "id": "try-it", |
298 | | - "metadata": {}, |
299 | | - "source": [ |
300 | | - "## Try It Yourself!\n", |
301 | | - "\n", |
302 | | - "Now experiment with the code above. Some ideas:\n", |
303 | | - "\n", |
304 | | - "1. **Change the ceiling/floor prices** - How does the shortage/surplus change as you move the control closer to equilibrium?\n", |
305 | | - "2. **Modify the demand and supply curves** - How do steeper or flatter curves affect the impact of controls?\n", |
306 | | - "3. **Calculate the percentage of DWL** - What fraction of the free market surplus is lost?\n", |
307 | | - "4. **Find the break-even point** - At what control price does consumer surplus equal producer surplus?" |
308 | | - ] |
309 | 189 | } |
310 | 190 | ], |
311 | 191 | "metadata": { |
|
0 commit comments