Path: blob/main/latex-templates/templates/economics/market_model.tex
51 views
unlisted
\documentclass[a4paper, 11pt]{report}1\usepackage[utf8]{inputenc}2\usepackage[T1]{fontenc}3\usepackage{amsmath, amssymb}4\usepackage{graphicx}5\usepackage{siunitx}6\usepackage{booktabs}7\usepackage{xcolor}8\usepackage[makestderr]{pythontex}910\definecolor{supply}{RGB}{46, 204, 113}11\definecolor{demand}{RGB}{231, 76, 60}12\definecolor{equilib}{RGB}{52, 152, 219}1314\title{Market Economics:\\15Supply, Demand, Elasticity, and Welfare Analysis}16\author{Department of Economics\\Technical Report EC-2024-002}17\date{\today}1819\begin{document}20\maketitle2122\begin{abstract}23This report presents a computational analysis of market models. We examine supply and demand curves, compute market equilibrium, analyze price elasticity, measure consumer and producer surplus, and evaluate the welfare effects of taxes and price controls.24\end{abstract}2526\tableofcontents2728\chapter{Introduction}2930Market equilibrium occurs where supply equals demand:31\begin{equation}32Q_d(P) = Q_s(P)33\end{equation}3435\section{Linear Supply and Demand}36\begin{align}37Q_d &= a - bP \quad \text{(Demand)} \\38Q_s &= c + dP \quad \text{(Supply)}39\end{align}4041Equilibrium: $P^* = \frac{a - c}{b + d}$, $Q^* = \frac{ad + bc}{b + d}$4243\begin{pycode}44import numpy as np45import matplotlib.pyplot as plt46from scipy.optimize import fsolve47from scipy.integrate import quad48plt.rc('text', usetex=True)49plt.rc('font', family='serif')5051np.random.seed(42)5253# Market parameters54a, b = 100, 1 # Demand: Q = a - b*P55c, d = 0, 2 # Supply: Q = c + d*P5657def demand(P):58return a - b * P5960def supply(P):61return c + d * P6263def inverse_demand(Q):64return (a - Q) / b6566def inverse_supply(Q):67return (Q - c) / d6869# Equilibrium70P_eq = (a - c) / (b + d)71Q_eq = a - b * P_eq7273# Elasticity functions74def price_elasticity_demand(P, Q):75return -b * P / Q7677def price_elasticity_supply(P, Q):78return d * P / Q7980# Welfare measures81def consumer_surplus(P_eq, Q_eq):82return 0.5 * (a/b - P_eq) * Q_eq8384def producer_surplus(P_eq, Q_eq):85return 0.5 * (P_eq - c/d) * Q_eq8687CS = consumer_surplus(P_eq, Q_eq)88PS = producer_surplus(P_eq, Q_eq)89\end{pycode}9091\chapter{Market Equilibrium}9293\begin{pycode}94fig, axes = plt.subplots(2, 2, figsize=(12, 10))9596# Basic supply and demand97ax = axes[0, 0]98P_range = np.linspace(0, 50, 100)99Q_d = demand(P_range)100Q_s = supply(P_range)101102ax.plot(Q_d, P_range, 'r-', linewidth=2, label='Demand')103ax.plot(Q_s, P_range, 'g-', linewidth=2, label='Supply')104ax.plot(Q_eq, P_eq, 'bo', markersize=10, zorder=5)105ax.axhline(P_eq, color='blue', linestyle='--', alpha=0.5)106ax.axvline(Q_eq, color='blue', linestyle='--', alpha=0.5)107ax.set_xlabel('Quantity $Q$')108ax.set_ylabel('Price $P$')109ax.set_title(f'Market Equilibrium: $P^* = {P_eq:.1f}$, $Q^* = {Q_eq:.1f}$')110ax.legend()111ax.set_xlim(0, 100)112ax.set_ylim(0, 50)113ax.grid(True, alpha=0.3)114115# Consumer and producer surplus116ax = axes[0, 1]117ax.plot(Q_d, P_range, 'r-', linewidth=2, label='Demand')118ax.plot(Q_s, P_range, 'g-', linewidth=2, label='Supply')119120# CS: area below demand, above price121Q_cs = np.linspace(0, Q_eq, 100)122P_cs = inverse_demand(Q_cs)123ax.fill_between(Q_cs, P_eq, P_cs, alpha=0.3, color='red', label='CS')124125# PS: area above supply, below price126Q_ps = np.linspace(0, Q_eq, 100)127P_ps = inverse_supply(Q_ps)128ax.fill_between(Q_ps, P_ps, P_eq, alpha=0.3, color='green', label='PS')129130ax.plot(Q_eq, P_eq, 'bo', markersize=10, zorder=5)131ax.set_xlabel('Quantity $Q$')132ax.set_ylabel('Price $P$')133ax.set_title(f'Welfare: CS = {CS:.1f}, PS = {PS:.1f}')134ax.legend()135ax.set_xlim(0, 100)136ax.set_ylim(0, 50)137ax.grid(True, alpha=0.3)138139# Effect of tax140tax = 10141P_buyers = P_eq + tax * b / (b + d)142P_sellers = P_eq - tax * d / (b + d)143Q_tax = demand(P_buyers)144145ax = axes[1, 0]146ax.plot(Q_d, P_range, 'r-', linewidth=2, label='Demand')147ax.plot(Q_s, P_range, 'g-', linewidth=2, label='Supply')148ax.plot(Q_s + tax * d, P_range, 'g--', linewidth=2, alpha=0.5, label='Supply + Tax')149150ax.plot(Q_eq, P_eq, 'bo', markersize=8, label='No tax')151ax.plot(Q_tax, P_buyers, 'rs', markersize=8, label='Buyer price')152ax.plot(Q_tax, P_sellers, 'gs', markersize=8, label='Seller price')153154# Tax revenue155ax.fill_between([Q_tax, Q_tax], [P_sellers, P_sellers], [P_buyers, P_buyers],156alpha=0.3, color='blue')157ax.annotate('Tax Revenue', xy=(Q_tax/2, (P_buyers + P_sellers)/2),158fontsize=9, ha='center')159160# Deadweight loss161ax.fill([Q_tax, Q_eq, Q_tax], [P_sellers, P_eq, P_buyers],162alpha=0.3, color='gray')163164ax.set_xlabel('Quantity $Q$')165ax.set_ylabel('Price $P$')166ax.set_title(f'Tax Effect: $\\tau = {tax}$')167ax.legend(loc='upper right', fontsize=8)168ax.set_xlim(0, 100)169ax.set_ylim(0, 50)170ax.grid(True, alpha=0.3)171172# Elasticity along demand curve173ax = axes[1, 1]174Q_range = np.linspace(1, 99, 100)175P_range_el = inverse_demand(Q_range)176elasticity = np.abs(price_elasticity_demand(P_range_el, Q_range))177178ax.plot(Q_range, elasticity, 'b-', linewidth=2)179ax.axhline(1, color='red', linestyle='--', alpha=0.5, label='Unit elastic')180ax.fill_between(Q_range, 0, elasticity, where=elasticity > 1, alpha=0.3, color='blue', label='Elastic')181ax.fill_between(Q_range, 0, elasticity, where=elasticity <= 1, alpha=0.3, color='green', label='Inelastic')182ax.set_xlabel('Quantity $Q$')183ax.set_ylabel('$|\\varepsilon_d|$')184ax.set_title('Price Elasticity of Demand')185ax.legend()186ax.grid(True, alpha=0.3)187ax.set_ylim(0, 10)188189plt.tight_layout()190plt.savefig('market_analysis.pdf', dpi=150, bbox_inches='tight')191plt.close()192193# Tax calculations194tax_revenue = tax * Q_tax195DWL = 0.5 * tax * (Q_eq - Q_tax)196elasticity_eq = price_elasticity_demand(P_eq, Q_eq)197\end{pycode}198199\begin{figure}[htbp]200\centering201\includegraphics[width=0.95\textwidth]{market_analysis.pdf}202\caption{Market analysis: (a) equilibrium, (b) welfare surplus, (c) tax effects, (d) elasticity.}203\end{figure}204205\chapter{Price Elasticity}206207\section{Definition}208Price elasticity of demand:209\begin{equation}210\varepsilon_d = \frac{\partial Q_d}{\partial P} \cdot \frac{P}{Q_d}211\end{equation}212213\begin{itemize}214\item $|\varepsilon_d| > 1$: Elastic (revenue increases with price decrease)215\item $|\varepsilon_d| < 1$: Inelastic (revenue decreases with price decrease)216\item $|\varepsilon_d| = 1$: Unit elastic217\end{itemize}218219\chapter{Welfare Analysis}220221\begin{pycode}222# Compare different market scenarios223fig, axes = plt.subplots(1, 3, figsize=(14, 4))224225# Price ceiling (below equilibrium)226ax = axes[0]227P_ceiling = P_eq - 10228Q_supplied = supply(P_ceiling)229Q_demanded = demand(P_ceiling)230231P_range = np.linspace(0, 50, 100)232ax.plot(demand(P_range), P_range, 'r-', linewidth=2, label='Demand')233ax.plot(supply(P_range), P_range, 'g-', linewidth=2, label='Supply')234ax.axhline(P_ceiling, color='blue', linestyle='-', linewidth=2, label='Price ceiling')235ax.fill_between([Q_supplied, Q_demanded], 0, P_ceiling, alpha=0.2, color='gray')236ax.annotate('Shortage', xy=((Q_supplied + Q_demanded)/2, P_ceiling/2),237fontsize=10, ha='center')238ax.set_xlabel('Quantity $Q$')239ax.set_ylabel('Price $P$')240ax.set_title('Price Ceiling (Shortage)')241ax.legend()242ax.set_xlim(0, 100)243ax.set_ylim(0, 50)244ax.grid(True, alpha=0.3)245246# Price floor (above equilibrium)247ax = axes[1]248P_floor = P_eq + 10249Q_supplied = supply(P_floor)250Q_demanded = demand(P_floor)251252ax.plot(demand(P_range), P_range, 'r-', linewidth=2, label='Demand')253ax.plot(supply(P_range), P_range, 'g-', linewidth=2, label='Supply')254ax.axhline(P_floor, color='orange', linestyle='-', linewidth=2, label='Price floor')255ax.fill_between([Q_demanded, Q_supplied], P_floor, 50, alpha=0.2, color='gray')256ax.annotate('Surplus', xy=((Q_demanded + Q_supplied)/2, (P_floor + 50)/2),257fontsize=10, ha='center')258ax.set_xlabel('Quantity $Q$')259ax.set_ylabel('Price $P$')260ax.set_title('Price Floor (Surplus)')261ax.legend()262ax.set_xlim(0, 100)263ax.set_ylim(0, 50)264ax.grid(True, alpha=0.3)265266# Demand shift267ax = axes[2]268a_new = 120 # Increased demand269P_eq_new = (a_new - c) / (b + d)270Q_eq_new = a_new - b * P_eq_new271272ax.plot(demand(P_range), P_range, 'r-', linewidth=2, alpha=0.5, label='$D_1$')273ax.plot(a_new - b * P_range, P_range, 'r--', linewidth=2, label='$D_2$')274ax.plot(supply(P_range), P_range, 'g-', linewidth=2, label='Supply')275ax.plot(Q_eq, P_eq, 'bo', markersize=8, label='Old eq')276ax.plot(Q_eq_new, P_eq_new, 'ro', markersize=8, label='New eq')277ax.annotate('', xy=(Q_eq_new, P_eq_new), xytext=(Q_eq, P_eq),278arrowprops=dict(arrowstyle='->', color='black'))279ax.set_xlabel('Quantity $Q$')280ax.set_ylabel('Price $P$')281ax.set_title('Demand Shift')282ax.legend()283ax.set_xlim(0, 120)284ax.set_ylim(0, 50)285ax.grid(True, alpha=0.3)286287plt.tight_layout()288plt.savefig('market_interventions.pdf', dpi=150, bbox_inches='tight')289plt.close()290\end{pycode}291292\begin{figure}[htbp]293\centering294\includegraphics[width=0.95\textwidth]{market_interventions.pdf}295\caption{Market interventions: price ceiling creates shortage, price floor creates surplus, demand shift moves equilibrium.}296\end{figure}297298\chapter{Numerical Results}299300\begin{pycode}301market_results = [302('Equilibrium price', f'{P_eq:.2f}', 'dollars'),303('Equilibrium quantity', f'{Q_eq:.2f}', 'units'),304('Consumer surplus', f'{CS:.2f}', 'dollars'),305('Producer surplus', f'{PS:.2f}', 'dollars'),306('Total welfare', f'{CS + PS:.2f}', 'dollars'),307('Elasticity at equilibrium', f'{abs(elasticity_eq):.2f}', ''),308('Tax revenue', f'{tax_revenue:.2f}', 'dollars'),309('Deadweight loss', f'{DWL:.2f}', 'dollars'),310]311\end{pycode}312313\begin{table}[htbp]314\centering315\caption{Market equilibrium results}316\begin{tabular}{@{}lcc@{}}317\toprule318Variable & Value & Units \\319\midrule320\py{market_results[0][0]} & \py{market_results[0][1]} & \py{market_results[0][2]} \\321\py{market_results[1][0]} & \py{market_results[1][1]} & \py{market_results[1][2]} \\322\py{market_results[2][0]} & \py{market_results[2][1]} & \py{market_results[2][2]} \\323\py{market_results[3][0]} & \py{market_results[3][1]} & \py{market_results[3][2]} \\324\py{market_results[4][0]} & \py{market_results[4][1]} & \py{market_results[4][2]} \\325\py{market_results[5][0]} & \py{market_results[5][1]} & \py{market_results[5][2]} \\326\py{market_results[6][0]} & \py{market_results[6][1]} & \py{market_results[6][2]} \\327\py{market_results[7][0]} & \py{market_results[7][1]} & \py{market_results[7][2]} \\328\bottomrule329\end{tabular}330\end{table}331332\chapter{Conclusions}333334\begin{enumerate}335\item Market equilibrium maximizes total welfare (CS + PS)336\item Taxes create deadweight loss proportional to elasticities337\item Price controls create shortages or surpluses338\item Elasticity determines tax incidence between buyers and sellers339\item Welfare analysis quantifies policy effects340\end{enumerate}341342\end{document}343344345