# Section 2

This notebook replicates Figure 2.1 in your textbook. The goal is to understand the Figure and the parameters. Then, you can play with them and analyze what happends with the equilibrium when you move them.   


```python
import collections
from pylab import *
import matplotlib
import matplotlib.pyplot as plt
import numpy as np
import sympy as sy
```

## Description:

$p_{Ch}$ and $q_{Ch}$ are the price and quantity of tea consumed in China, respectively. The inverse demand function for tea in China is

$p_{Ch} = 20 - q_{Ch}$, where 20 is the choke price for China

$p_{US}$ and $q_{US}$ are the price and quantity of tea consumed in the U.S., respectively. The total quantity of tea, $q_T$, is 10. Then, the quantity in the U.S., $q_{US}$, is total quantity minus the quantity in China, $q_{Ch}$. 

$q_{US} = 10 - q_{Ch}$

The inverse demand function for tea in the U.S. is

$p_{US} = 18 - q_{US} = 18 - (10 - q_{Ch})$, where 18 is the choke price for the U.S.

## Parameters: 

You can change the parameters below to analize what happens with the equilibrium.


```python
aCh = 20 # choke price for China
aUS = 18 # choke price for the U.S.
qT = 10 # total quantity 
b = 0 # transportation cost 
```

We consider iceberg transportation cost. For instance, $b=0.3$ implies tranportation costs equals to 30\% of the purchase price. How do transportation costs affect the equilibrium price and quantity in the two markets?

## Equilibrium:

First, we calculate the price and equilibrium quantities. If you change the parameters above the equilibrium will change. Don't change the code below!


```python
# Equilibrium
EqCh = (qT + ((1+b)*aCh) - aUS)/(2+b) # quantity in China
EqUS = qT - EqCh # quantity in the U.S.
EpCh = aCh - EqCh # price
EpUS = (1+b)*EpCh

```


```python
print("The equilibrium price in China is", "{:.2f}".format(EpCh),
      "The equilibrium price in the U.S. is", "{:.2f}".format(EpUS),
      ",the equilibrium quantity in China is", "{:.2f}".format(EqCh),
      " and the equilibrium quantity in the U.S.(transportation-inclusive) is", "{:.2f}".format(EqUS),
      sep=" ")
```

    The equilibrium price in China is 14.00 The equilibrium price in the U.S. is 14.00 ,the equilibrium quantity in China is 6.00  and the equilibrium quantity in the U.S.(transportation-inclusive) is 4.00


## Figure 2.1

The code below replicates Figure 2.1 in your texbook. Don't change it!  


```python
qCh = np.linspace(0, qT, 10) # quantity in China
pCh = aCh - qCh # price in China
qUS = np.linspace(0, qT, 10)  # quantity in the U.S.
pUS = (1/(1+b))*(aUS - (qT - qCh)) # price in the U.S.

fig, ax1 = plt.subplots()
ax2 = ax1.twinx()
ax1.plot(qCh, pCh, 'g-')
ax2.plot(qUS, pUS, 'b-')
ax1.plot(EqCh, EpCh, 'o', markersize = 10)

ax1.set_xlabel('tea')
ax1.set_ylabel('price')
ax2.set_ylabel('price')

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


title('Arbitrage')
show()

```

0038b4b64d1df4a880c530cbf9149997c820a36a
ipynb
Jupyter Notebook
Notebook_2.ipynb
ds-modules/EEP102
ec167a2880af093bc78e9c6ea0af72b1d681722d
BSD-3-Clause
Notebook_2.ipynb
ds-modules/EEP102
ec167a2880af093bc78e9c6ea0af72b1d681722d
BSD-3-Clause
Notebook_2.ipynb
ds-modules/EEP102
ec167a2880af093bc78e9c6ea0af72b1d681722d
BSD-3-Clause
2019-10-27T08:10:24.000Z
2019-12-07T07:01:11.000Z
Qwen/Qwen-72B
1. YES
2. YES