<jupyter_start><jupyter_text>Section 3This notebook replicates Figure 3.1 and Figure 3.2 in your book.<jupyter_code>import collections
from pylab import *
import matplotlib
import matplotlib.pyplot as plt
import numpy as np<jupyter_output><empty_output><jupyter_text>DescriptionHere we study the competitive equilibrium for the two-period nonrenewable resource model. We focus in the simplest case where the initial stock is small enough that firms wants to exhaust the resource during this time. The first period is denoted $t=0$ and the second period by $t=1$. A price taking firm has a discount factor $\rho$ , faces prices $p_0$ and $p_1$ in period 0 and 1, incurs extraction cost $c$ for each unit extracted, and has a fix stock of the resource, $x$ units. The inverse demand function is $p = a - y$. The no-intertemporal arbitrag condition states that the firm cannot increase its profits by moving sales from one period to another. $$ (p_0 - c) = \rho (p_1 - c) $$  Parameters<jupyter_code>a = 20 # choke price
x = 10 # total quantity
c = 1 # constant marginal costs 
rho = 0.8 # discount factor<jupyter_output><empty_output><jupyter_text>Equlibrium<jupyter_code>#Equilibrium

Ey0 = ((a - c)*(1 - rho)+(rho*x))/(1 + rho)
Ep0 = a - Ey0
Ey1 = x - Ey0
Ep1 = a - Ey1

print("The equilibrium price in period 0 is", "{:.2f}".format(Ep0),
      ".The equilibrium quantity in period 0 is", "{:.2f}".format(Ey0),
      ".The equilibrium price in period 1 is", "{:.2f}".format(Ep1),
      ".The equilibrium quantity in period 1 is", "{:.2f}".format(Ey1),
      sep=" ")<jupyter_output>The equilibrium price in period 0 is 13.44 .The equilibrium quantity in period 0 is 6.56 .The equilibrium price in period 1 is 16.56 .The equilibrium quantity in period 1 is 3.44<jupyter_text>FigureThe code below replicates Figure 3.1 and Figure 3.2 in your texbook. Don't change it!<jupyter_code>y0 = np.linspace(0, 10, 2)
R0 = a - y0 -c
y1 = np.linspace(0, 10, 2)
rhoR1 = rho*(a -(x-y0)-c)
R1 = (a -(x-y0)-c)

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(y0, R0, 'g-')
ax2.plot(y1, rhoR1, 'b-')
ax2.plot(y1, R1, 'b-',linestyle='dashed')

ax1.set_xlabel('Extraction (y0)')
ax1.set_ylabel('$')
ax2.set_ylabel('$')

ax1.set_ylim([0,25])
ax2.set_ylim([0,25])

title('Equilibrium extraction with discounting')
show()<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.12601800257179596, 'fraction_numerical': 0.04414916416630947, 'mean_word_length': 4.440559440559441, 'pattern_counts': {'":': 0, '<': 16, '<?xml version=': 0, '>': 16, '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': '4', 'dir': 'jupyter-structured-clean-dedup', 'id': '242828', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 886, 'n_tokens_neox': 818, 'n_words': 295, 'path': 'Notebook 3.ipynb', 'repo_name': 'ds-modules/EEP102', 'size': '2333'}