-
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
-
Surplus and Shortage
Let’s talk about what happens when the price is not the equilibrium price. We get either a surplus when the price is too high and more people want to supply, or a shortage when the price is too low and more people want to buy the product. What we will do is graph what the two quantities (demanded and supplied) are when we have a price that isn’t the equilibrium. Let’s start with a price too high, a price of 8.
import matplotlib.pyplot as plt
plt.plot(demandQ,prices)
plt.plot(supplyQ,prices)
unitsDemanded = demandEquation.subs(p,8)
unitsSupplied = supplyEquation.subs(p,8)
plt.plot(unitsDemanded,8, 'ro')
plt.plot(unitsSupplied,8, 'ro')
plt.plot([unitsDemanded,unitsSupplied],[8,8],":")
plt.xlabel("Supply and Demand")
plt.ylabel("Price")
plt.show()
surplus = unitsSupplied-unitsDemanded
print("The surplus is equal to "+str(surplus)+" units.")
We use unitsDemanded and unitsSupplied to figure out what quantity would be according to the supply or demand curve. We use plt.plot([unitsDemanded,unitsSupplied],[8,8],”:”) to plot a dotted line between the two points. [unitsDemanded,unitsSupplied] are our x coordinates, and [8,8] are our y coordinates. “:” tells our plotter to plot the line as a dashed line. Finally, print(“The surplus is equal to “+str(surplus)+” units.”) prints out a line with what our surplus is. We can add strings together just like numbers to make longer strings. Also str() turns something that is not a string into a string (this allows us to add the number to our existing string). Now let’s do the same for the shortage.
import matplotlib.pyplot as plt
plt.plot(demandQ,prices)
plt.plot(supplyQ,prices)
unitsDemanded = demandEquation.subs(p,2)
unitsSupplied = supplyEquation.subs(p,2)
plt.plot(unitsDemanded,2, 'ro')
plt.plot(unitsSupplied,2, 'ro')
plt.plot([unitsDemanded,unitsSupplied],[2,2],":")
plt.xlabel("Supply and Demand")
plt.ylabel("Price")
plt.show()
shortage = unitsDemanded-unitsSupplied
print("The shortage is equal to "+str(shortage)+" units.")
The above code is very similar except we replaced the price of 8 with a price of 2, yielding a shortage of supply/excess of demand.
An important thing to realize is that markets tend to correct, so while a price might not be at the equilibrium, it generally will fall back to it over time. If there was a surplus, then companies might go bankrupt, leading to less supply, for example.
Source Code