cobweb_model_documentation_with_example
cobweb_model_documentation_with_example
To solve the cobweb model problem numerically based on the given equations:
Solution:
1. Demand Equation: Qd=12.4−1.2PQ_d = 12.4 - 1.2PQd=12.4−1.2P
The goal is to find the next price PtP_tPt and quantity QtQ_tQt over a few periods.
Steps to Solve
3. Plug QdQ_dQd into the supply equation to calculate the next price PtP_tPt.
Calculations
Period 0:
Period 1:
1. Quantity demanded:
Qd=12.4−1.2P0Q_d = 12.4 - 1.2P_0Qd=12.4−1.2P0
Qd=12.4−1.2(1.0)=11.2Q_d = 12.4 - 1.2(1.0) = 11.2Qd
=12.4−1.2(1.0)=11.2.
Period 2:
1. Quantity demanded:
Qd=12.4−1.2P1Q_d = 12.4 - 1.2P_1Qd=12.4−1.2P1.
Qd=12.4−1.2(−5.33)=12.4+6.396=18.796Q_d = 12.4 - 1.2(-5.33) = 12.4 +
6.396 = 18.796Qd=12.4−1.2(−5.33)=12.4+6.396=18.796.
Period 3:
1. Quantity demanded:
Qd=12.4−1.2P2Q_d = 12.4 - 1.2P_2Qd=12.4−1.2P2.
Qd=12.4−1.2(−17.99)=12.4+21.588=33.988Q_d = 12.4 - 1.2(-17.99) = 12.4
+ 21.588 = 33.988Qd=12.4−1.2(−17.99)=12.4+21.588=33.988.
Summary Table:
0 1.0 11.2
1 -5.33 18.796
2 -17.99 33.988
3 -43.31 65.972
Code:
import numpy as np
import matplotlib.pyplot as plt
def supply(price_previous):
return 8.0 - 0.6 * price_previous
# Initialize lists to store price and quantity values for each period
P0 = 1.0 # Initial price
prices = [P0]
quantities = [demand(P0)]
# Plotting
fig, ax = plt.subplots(figsize=(10, 8)) # Adjusted figure size