πŸ”¬ Tutorial problems lambda

πŸ”¬ Tutorial problems lambda#

Hide code cell content
import numpy as np
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
from matplotlib import cm
from myst_nb import glue

f = lambda x: (x[0])**3 - (x[1])**3
lb,ub = -1.5,1.5

x = y = np.linspace(lb,ub, 100)
X, Y = np.meshgrid(x, y)
zs = np.array([f((x,y)) for x,y in zip(np.ravel(X), np.ravel(Y))])
Z = zs.reshape(X.shape)

a,b=1,1
# (x/a)^2 + (y/b)^2 = 1
theta = np.linspace(0, 2 * np.pi, 100)
X1 = a*np.cos(theta)
Y1 = b*np.sin(theta)
zs = np.array([f((x,y)) for x,y in zip(np.ravel(X1), np.ravel(Y1))])
Z1 = zs.reshape(X1.shape)

fig = plt.figure(dpi=160)
ax2 = fig.add_subplot(111)
ax2.set_aspect('equal', 'box')
ax2.contour(X, Y, Z, 50,
            cmap=cm.jet)
ax2.plot(X1, Y1)
plt.setp(ax2, xticks=[],yticks=[])
glue("pic1", fig, display=False)

fig = plt.figure(dpi=160)
ax3 = fig.add_subplot(111, projection='3d')
ax3.plot_wireframe(X, Y, Z,
            rstride=2,
            cstride=2,
            alpha=0.7,
            linewidth=0.25)
f0 = f(np.zeros((2)))+0.1
ax3.plot(X1, Y1, Z1, c='red')
plt.setp(ax3,xticks=[],yticks=[],zticks=[])
ax3.view_init(elev=18, azim=154)
glue("pic2", fig, display=False)


f = lambda x: x[0]**3/3 - 3*x[1]**2 + 5*x[0] - 6*x[0]*x[1]
x = y = np.linspace(-10.0, 10.0, 100)
X, Y = np.meshgrid(x, y)
zs = np.array([f((x,y)) for x,y in zip(np.ravel(X), np.ravel(Y))])
Z = zs.reshape(X.shape)
a,b=4,8
# (x/a)^2 + (y/b)^2 = 1
theta = np.linspace(0, 2 * np.pi, 100)
X1 = a*np.cos(theta)
Y1 = b*np.sin(theta)
zs = np.array([f((x,y)) for x,y in zip(np.ravel(X1), np.ravel(Y1))])
Z1 = zs.reshape(X1.shape)

fig = plt.figure(dpi=160)
ax2 = fig.add_subplot(111)
ax2.set_aspect('equal', 'box')
ax2.contour(X, Y, Z, 50,
            cmap=cm.jet)
ax2.plot(X1, Y1)
plt.setp(ax2, xticks=[],yticks=[])
glue("pic3", fig, display=False)

fig = plt.figure(dpi=160)
ax3 = fig.add_subplot(111, projection='3d')
ax3.plot_wireframe(X, Y, Z, 
            rstride=2, 
            cstride=2,
            alpha=0.7,
            linewidth=0.25)
f0 = f(np.zeros((2)))+0.1
ax3.plot(X1, Y1, Z1, c='red')
plt.setp(ax3,xticks=[],yticks=[],zticks=[])
ax3.view_init(elev=18, azim=154)
glue("pic4", fig, display=False)
_images/9207bfd219ca984986a6a92fcc0bd03860754af19875606a5080bad763c06d77.png _images/0e28951d63b7f95b342f37426df0f85f6dbaddc37e9eb5b016cbc259821c147a.png _images/9c6f524d6b0a7902469c59abf1311c8d582f92ee14c84d8543831366fabc4433.png _images/d1641a091417d258e07db925184992333893dee5474522b444ef7de3ab6b398e.png

\(\lambda\).1#

Solve the following constrained maximization problem using the Karush-Kuhn-Tucker method. Verify that the found stationary/critical points satisfy the second order conditions.

\[\begin{split} \begin{array}{c} f(x,y) = x^3 - y^3 \to \max_{x,y}\\ \text {subject to} \\ x^2 + y^2 \le 1,\\ x,y \in \mathbb{R} \end{array} \end{split}\]

Standard KKT method should work for this problem.

_images/9207bfd219ca984986a6a92fcc0bd03860754af19875606a5080bad763c06d77.png

Fig. 100 Level curves of the criterion function and constraint curve.#

_images/0e28951d63b7f95b342f37426df0f85f6dbaddc37e9eb5b016cbc259821c147a.png

Fig. 101 3D plot of the criterion surface with the constraint curve projected to it.#

⏱

\(\lambda\).2#

Solve the following constrained maximization problem using the Karush-Kuhn-Tucker method. Verify that the found stationary/critical points satisfy the second order conditions.

\[\begin{split} \begin{array}{c} f(x,y) = -x^2 \to \max_{x,y} \\ \text {subject to} \\ x^2-y^2-2xy \ge 2,\\ x,y \in \mathbb{R} \end{array} \end{split}\]

Standard KKT method should work for this problem.

⏱

\(\lambda\).3#

Roy’s identity

Consider the choice problem of a consumer endowed with strictly concave and differentiable utility function \(u \colon \mathbb{R}^N_{++} \to \mathbb{R}\) where \(\mathbb{R}^N_{++}\) denotes the set of vector in \(\mathbb{R}^N\) with strictly positive elements.

The budget constraint is given by \({\bf p}\cdot{\bf x} \le m\) where \({\bf p} \in \mathbb{R}^N_{++}\) are prices and \(m>0\) is income.

Then the demand function \(x^\star({\bf p},m)\) and the indirect utility function \(v({\bf p},m)\) (value function of the problem) satisfy the equations

\[ x_i^\star({\bf p},m) = -\frac{\partial v}{\partial p_i}({\bf p},m) \Big/ \frac{\partial v}{\partial m}({\bf p},m), \; \forall i \in \{1,\dots,N\} \]
  1. Prove the statement

  2. Verify the statement by direct calculation (i.e. by expressing the indirect utility and plugging its partials into the identity) using the following specification of utility

\[ u({\bf x}) = \prod_{i=1}^N x_i^{\alpha_i}, \; \alpha_i > 0 \]

Envelope theorem should be useful here.

⏱