First let's do some standard imports and set up commands
%matplotlib inline
import numpy as np
import matplotlib.pyplot as plt
Let's consider a market for kiwi fruit. The supply curve is
$$ q_s(p) = \exp(b p) - 1. $$The demand curve is
$$ q_d(p) = a p^{-\epsilon}. $$The values $a$, $b$ and $\epsilon$ are parameters
The equilibrium $p^*$ is the price such that $q_d(p) = q_s(p)$.
Let's try to find the equilibrium price visually when
def supply(p, b):
return np.exp(b * p) - 1
def demand(p, a, epsilon):
return a * p**(-epsilon)
b, a, epsilon = 0.1, 1, 1
grid = np.linspace(2, 4, 100)
fig, ax = plt.subplots(figsize=(8, 6))
ax.plot(grid, demand(grid, a, epsilon), 'b-', lw=2, label='demand')
ax.plot(grid, supply(grid, b), 'g-', lw=2, label='supply')
ax.set_xlabel('price', fontsize=14)
ax.set_ylabel('quantity', fontsize=14)
ax.grid()
ax.legend(loc='upper center')
<matplotlib.legend.Legend at 0x7fdb257fda90>
Try to change the figure above so that it shows both the old and the new demand curves (at $\epsilon = 1$ and $\epsilon = 1.45$)
Write a new function excess supply (supply - demand) as a function of price and all parameters
Change the above figure so that it shows excess supply
for i in range(40):
print("Solution is below")
Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below Solution is below
def excess_supply(p, a, b, epsilon):
return supply(p, b) - demand(p, a, epsilon)
grid = np.linspace(2, 4, 100)
y = excess_supply(grid, a, b, epsilon)
fig, ax = plt.subplots(figsize=(8, 6))
ax.plot(grid, y, 'r-', lw=2, label='excess supply')
ax.plot(grid, 0 * grid, 'k-')
ax.set_xlabel('price', fontsize=14)
ax.set_ylabel('quantity', fontsize=14)
ax.grid()
ax.legend(loc='upper center')
<matplotlib.legend.Legend at 0x7fdb25143c50>