<jupyter_start><jupyter_text>Constrained Maximization ProblemThe consumer chooses $\mathbf{x} = (x_1, x_2)$ to solve,\begin{align}    \max_{\mathbf{x}} &\; U(\mathbf{x}) = x_1^{\alpha} x_2^{\beta} \\    s.t. &\; \mathbf{p}\cdot \mathbf{x} = w\end{align}where $\mathbf{p} = (p_1, p_2) \gg \mathbf{0}$  Convert to Unconstrained ProblemWe can convert the constrained optimization problem by forming the *Lagrangian* function as our objective function.\begin{align}    \mathcal{L}(\mathbf{x},\lambda) &= U(\mathbf{x}) + \lambda \left(w - \mathbf{p}\cdot \mathbf{x} \right) \\    &= x_1^{\alpha} x_2^{\beta} + \lambda (w - p_1 x_1 - p_2 x_2)\end{align}Using this as the objective function we can derive the first order condition for a maximum (yielding the *critical points*) and test the second order condition at those critical points to verify we have a local maximum and not a minimum or saddle point.<jupyter_code>Lagrange =  U + L*budget_constraint

Lagrange_x1 = Lagrange.diff(x1)
Lagrange_x2 = Lagrange.diff(x2)
Lagrange_L = Lagrange.diff(L)

Lagrange_x1, Lagrange_x2, Lagrange_L<jupyter_output><empty_output><jupyter_text>We solve the first two conditions (partial w.r.t. $x_1,x_2$) for the multiplier $\lambda$ and then set them equal to each other to get rid of the $\lambda$ term and solve for $x_1$ in terms of $x_2$ and parameters.<jupyter_code>term1 = solve(Lagrange_x1, L)[0].simplify()
term2 = solve(Lagrange_x2, L)[0]

x1_temp = solve(term1 - term2, x1)[0].simplify()
Eq(x1, x1_temp)<jupyter_output><empty_output><jupyter_text>Now we can substitute our expression for $x_1$, that summarizes the first 2 conditions, into the third first order condition (associated with $\lambda$), solve for $x_2$ to get the **Marshalian Demand** function for $x_2$.<jupyter_code>subbed_term = Lagrange_L.subs(x1, x1_temp)
x2_star = solve(subbed_term, x2)[0]
Eq(Symbol('x_2^*'), x2_star)<jupyter_output><empty_output><jupyter_text>We can now substitute the demand function $x_2^*(\mathbf{p},w)$ into another first order condition, solve for $x_1$ to get its demand function.<jupyter_code>subbed_term = Lagrange_L.subs(x2, x2_star)
x1_star = solve(subbed_term, x1)[0]
Eq(Symbol('x_1^*'), x1_star)<jupyter_output><empty_output><jupyter_text>Now that we know $x_1^*$ and $x_2^*$ we can substitute them into one the first order conditions that were solved for $\lambda$ and derive the optimal Lagrange multiplier value (which represents the marginal utility of wealth at the optimal choice).<jupyter_code>L_star = term1.subs([(x1, x1_star), (x2, x2_star)]).simplify()
Eq(Symbol('lambda^*'), L_star)<jupyter_output><empty_output><jupyter_text>The Walrasian demand is the "argmax" of the utility maximization problem.\begin{align}    \mathbf{x}(\mathbf{p},w) &= (x_1^*(\mathbf{p},w), x_2^*(\mathbf{p},w))\end{align}substituting the solutions to the maximization problem into the utility function we can derive the **indirect utility**.<jupyter_code>V = U.subs([(x1, x1_star), (x2, x2_star)]).simplify()
Eq(Symbol('V(\mathbf{p},w)'), V)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.14042553191489363, 'fraction_numerical': 0.02258592471358429, 'mean_word_length': 6.074074074074074, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '242448', 'license': 'MIT', 'n_tokens_mistral': 1099, 'n_tokens_neox': 1060, 'n_words': 306, 'path': 'assets/pdfs/math_bootcamp/notebooks/utility_maximization_cobb_douglas.ipynb', 'repo_name': 'joepatten/joepatten.github.io', 'size': '3055'}