-
Introduction 4
-
Lecture1.1
-
Lecture1.2
-
Lecture1.3
-
Lecture1.4
-
-
Production Possibilities Frontier 4
-
Lecture2.1
-
Lecture2.2
-
Lecture2.3
-
Lecture2.4
-
-
Trade 3
-
Lecture3.1
-
Lecture3.2
-
Lecture3.3
-
-
Demand 4
-
Lecture4.1
-
Lecture4.2
-
Lecture4.3
-
Lecture4.4
-
-
Supply 2
-
Lecture5.1
-
Lecture5.2
-
-
Equilibrium 4
-
Lecture6.1
-
Lecture6.2
-
Lecture6.3
-
Lecture6.4
-
-
Curve Movements 4
-
Lecture7.1
-
Lecture7.2
-
Lecture7.3
-
Lecture7.4
-
-
Elasticity and Revenue 5
-
Lecture8.1
-
Lecture8.2
-
Lecture8.3
-
Lecture8.4
-
Lecture8.5
-
-
Taxes 7
-
Lecture9.1
-
Lecture9.2
-
Lecture9.3
-
Lecture9.4
-
Lecture9.5
-
Lecture9.6
-
Lecture9.7
-
-
Consumer and Producer Surplus 8
-
Lecture10.1
-
Lecture10.2
-
Lecture10.3
-
Lecture10.4
-
Lecture10.5
-
Lecture10.6
-
Lecture10.7
-
Lecture10.8
-
-
Imports and Exports 4
-
Lecture11.1
-
Lecture11.2
-
Lecture11.3
-
Lecture11.4
-
-
Tariffs 2
-
Lecture12.1
-
Lecture12.2
-
Creating the Shift Function
This function is very similar to our equilibrium function, except we find two different equilibriums, for before and after the shift.
def demandShift(demandEquation1,demandEquation2,supplyEquation,priceStart,priceEnd):
prices = []
demandQ1 = []
demandQ2 = []
supplyQ = []
for price in range(priceStart,priceEnd+1):
prices += [price]
demandQ1 += [demandEquation1.subs(p,price)]
demandQ2 += [demandEquation2.subs(p,price)]
supplyQ += [supplyEquation.subs(p,price)]
equilibriumP1 = sy.solve(demandEquation1-supplyEquation)[0]
equilibriumQ1 = demandEquation1.subs(p,equilibriumP1)
equilibriumP2 = sy.solve(demandEquation2-supplyEquation)[0]
equilibriumQ2 = demandEquation2.subs(p,equilibriumP2)
plt.plot(demandQ1,prices)
plt.plot(demandQ2,prices)
plt.plot(supplyQ,prices)
plt.legend(["Old Demand","New Demand","Supply"])
plt.plot(equilibriumQ1,equilibriumP1, 'ro')
plt.plot(equilibriumQ2,equilibriumP2, 'ro')
plt.xlabel("Supply and Demand Quantity")
plt.ylabel("Price")
plt.show()
print("The old equilibrium price is "+str(equilibriumP1)+" and old equilibrium quantity is "+str(equilibriumQ1)+".")
print("The new equilibrium price is "+str(equilibriumP2)+" and new equilibrium quantity is "+str(equilibriumQ2)+".")
print("The price shifted "+str(equilibriumP2-equilibriumP1)+" and the quantity shifted "+str(equilibriumQ2-equilibriumQ1)+".")
demandShift(10-p,15-p,p,0,10)
Our curve shift function shows what happens when the demand curve goes from 10-p to 15-p. Both the price and the quantity move upwards with a higher demand. Now what if the supply curve doubled at every point?
def supplyShift(demandEquation,supplyEquation1,supplyEquation2,priceStart,priceEnd):
prices = []
demandQ = []
supplyQ1 = []
supplyQ2 = []
for price in range(priceStart,priceEnd+1):
prices += [price]
demandQ += [demandEquation.subs(p,price)]
supplyQ1 += [supplyEquation1.subs(p,price)]
supplyQ2 += [supplyEquation2.subs(p,price)]
equilibriumP1 = sy.solve(demandEquation-supplyEquation1)[0]
equilibriumQ1 = demandEquation.subs(p,equilibriumP1)
equilibriumP2 = sy.solve(demandEquation-supplyEquation2)[0]
equilibriumQ2 = demandEquation.subs(p,equilibriumP2)
plt.plot(demandQ,prices)
plt.plot(supplyQ1,prices)
plt.plot(supplyQ2,prices)
plt.legend(["Old Demand","Old Supply","New Supply"])
plt.plot(equilibriumQ1,equilibriumP1, 'ro')
plt.plot(equilibriumQ2,equilibriumP2, 'ro')
plt.xlabel("Supply and Demand Quantity")
plt.ylabel("Price")
plt.show()
print("The old equilibrium price is "+str(equilibriumP1)+" and old equilibrium quantity is "+str(equilibriumQ1)+".")
print("The new equilibrium price is "+str(equilibriumP2)+" and new equilibrium quantity is "+str(equilibriumQ2)+".")
print("The price shifted "+str(equilibriumP2-equilibriumP1)+" and the quantity shifted "+str(equilibriumQ2-equilibriumQ1)+".")
supplyShift(10-p,p,2*p,0,10)
When the supply is increased we see more quantity again, but this time we see decreasing prices. What if both curves shift? We actually can’t tell what will happen without doing anaylsis because the two shifts can have opposite effects for either price and/or quantity
def dualShift(demandEquation1,demandEquation2,supplyEquation1,supplyEquation2,priceStart,priceEnd):
prices = []
demandQ1 = []
demandQ2 = []
supplyQ1 = []
supplyQ2 = []
for price in range(priceStart,priceEnd+1):
prices += [price]
demandQ1 += [demandEquation1.subs(p,price)]
demandQ2 += [demandEquation2.subs(p,price)]
supplyQ1 += [supplyEquation1.subs(p,price)]
supplyQ2 += [supplyEquation2.subs(p,price)]
equilibriumP1 = sy.solve(demandEquation1-supplyEquation1)[0]
equilibriumQ1 = demandEquation1.subs(p,equilibriumP1)
equilibriumP2 = sy.solve(demandEquation2-supplyEquation2)[0]
equilibriumQ2 = demandEquation2.subs(p,equilibriumP2)
plt.plot(demandQ1,prices)
plt.plot(demandQ2,prices)
plt.plot(supplyQ1,prices)
plt.plot(supplyQ2,prices)
plt.legend(["Old Demand","New Demand","Old Supply","New Supply"])
plt.plot(equilibriumQ1,equilibriumP1, 'ro')
plt.plot(equilibriumQ2,equilibriumP2, 'ro')
plt.xlabel("Supply and Demand Quantity")
plt.ylabel("Price")
plt.show()
print("The old equilibrium price is "+str(equilibriumP1)+" and old equilibrium quantity is "+str(equilibriumQ1)+".")
print("The new equilibrium price is "+str(equilibriumP2)+" and new equilibrium quantity is "+str(equilibriumQ2)+".")
print("The price shifted "+str(equilibriumP2-equilibriumP1)+" and the quantity shifted "+str(equilibriumQ2-equilibriumQ1)+".")
dualShift(10-p,15-p,p,2*p,0,10)
The code above creates a shift that does not change price. This, however, is not always the case.
Source Code