<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Equilibrium Price, Take 2
Jan 2016
First we import some functionality from the scientific libraries
Step1:  Now let's write routines to compute supply and demand as functions of price and parameters
Step2:  Next we'll write a function that takes a parameter set and returns a market clearing price via bisection
Step3:  Let's test it with the original parameter set, the market clearing price for which was 2.9334.  The parameters are
$$ a = 1, \quad b = 0.1, \quad \epsilon = 1 $$
Step4:  Let's see this visually.  First we import the plotting library matplotlib in the standard way
Step5:  The next command is a Jupyter "line magic" that tells Jupyter to display figures in the browser
Step6:  Now let's plot supply and demand on a grid of points
Step7:  Now let's output market clearing prices for all parameter configurations given in exercise 1 of the homework.
<ASSISTANT_TASK:>
Python Code:
import numpy as np
from scipy.optimize import bisect
Explanation: Equilibrium Price, Take 2
Jan 2016
First we import some functionality from the scientific libraries
End of explanation
def supply(price, b):
    return np.exp(b * price) - 1
def demand(price, a, epsilon):
    return a * price**(-epsilon)
Explanation: Now let's write routines to compute supply and demand as functions of price and parameters:
End of explanation
def compute_equilibrium(a, b, epsilon):
    plow = 0.1
    phigh = 10.0
    def excess_supply(price):
        return supply(price, b) - demand(price, a, epsilon)
    pclear = bisect(excess_supply, plow, phigh)
    return pclear
Explanation: Next we'll write a function that takes a parameter set and returns a market clearing price via bisection:
End of explanation
compute_equilibrium(1, 0.1, 1)
Explanation: Let's test it with the original parameter set, the market clearing price for which was 2.9334.  The parameters are
$$ a = 1, \quad b = 0.1, \quad \epsilon = 1 $$
End of explanation
import matplotlib.pyplot as plt
Explanation: Let's see this visually.  First we import the plotting library matplotlib in the standard way:
End of explanation
%matplotlib inline
Explanation: The next command is a Jupyter "line magic" that tells Jupyter to display figures in the browser:
End of explanation
grid_size = 100
grid = np.linspace(2, 4, grid_size)
fig, ax = plt.subplots(figsize=(8, 6))
ax.plot(grid, demand(grid, 1, 1), 'b-', label='demand')
ax.plot(grid, supply(grid, 0.1), 'g-', label='supply')
ax.set_xlabel('price', fontsize=14)
ax.set_ylabel('quantity', fontsize=14)
ax.legend(loc='upper center', frameon=False)
Explanation: Now let's plot supply and demand on a grid of points
End of explanation
parameter_list = [[1, 0.1, 1],
                  [2, 0.1, 1],
                  [1, 0.2, 1],
                  [1, 0.1, 2]]
for parameters in parameter_list:
    print("Price = {}".format(compute_equilibrium(*parameters)))
Explanation: Now let's output market clearing prices for all parameter configurations given in exercise 1 of the homework.
End of explanation
<END_TASK>