0% found this document useful (0 votes)
77 views

cobweb_model_documentation_with_example

Uploaded by

MD Raihan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
77 views

cobweb_model_documentation_with_example

Uploaded by

MD Raihan
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 5

Title: Solve the cobweb model problem;

To solve the cobweb model problem numerically based on the given equations:

1. Demand Equation: D=12.4−1.2PD = 12.4 - 1.2PD=12.4−1.2P

2. Supply Equation: S=8.0−0.6Pt−1S = 8.0 - 0.6P_{t-1}S=8.0−0.6Pt−1

3. Initial Price: P0=1.0P_0 = 1.0P0=1.0

Solution:
1. Demand Equation: Qd=12.4−1.2PQ_d = 12.4 - 1.2PQd=12.4−1.2P

2. Supply Equation: Qs=8.0−0.6Pt−1Q_s = 8.0 - 0.6P_{t-1}Qs=8.0−0.6Pt−1

3. Initial Price: P0=1.0P_0 = 1.0P0=1.0

The goal is to find the next price PtP_tPt and quantity QtQ_tQt over a few periods.

Steps to Solve

1. Start with the initial price P0=1.0P_0 = 1.0P0=1.0.

2. Use the demand equation to calculate quantity QdQ_dQd.

3. Plug QdQ_dQd into the supply equation to calculate the next price PtP_tPt.

4. Repeat for a few periods.

Calculations

Period 0:

 P0=1.0P_0 = 1.0P0=1.0 (given).

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.

2. Next Price P1P_1P1 (using supply equation):


Qs=8.0−0.6P0Q_s = 8.0 - 0.6P_0Qs=8.0−0.6P0 → Rearrange to find P1P_1P1:
P1=8.0−Qd0.6P_1 = \frac{8.0 - Q_d}{0.6}P1=0.68.0−Qd.
P1=8.0−11.20.6=−5.33P_1 = \frac{8.0 - 11.2}{0.6} = -5.33P1=0.68.0−11.2
=−5.33.

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.

2. Next Price P2P_2P2:


P2=8.0−Qd0.6P_2 = \frac{8.0 - Q_d}{0.6}P2=0.68.0−Qd.
P2=8.0−18.7960.6=−17.99P_2 = \frac{8.0 - 18.796}{0.6} = -17.99P2
=0.68.0−18.796=−17.99.

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.

2. Next Price P3P_3P3:


P3=8.0−Qd0.6P_3 = \frac{8.0 - Q_d}{0.6}P3=0.68.0−Qd.
P3=8.0−33.9880.6=−43.31P_3 = \frac{8.0 - 33.988}{0.6} = -43.31P3
=0.68.0−33.988=−43.31.

Summary Table:

Period (ttt) Price (PtP_tPt) Quantity Demanded (QdQ_dQd)

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

# Define the demand and supply functions


def demand(price):
return 12.4 - 1.2 * price

def supply(price_previous):
return 8.0 - 0.6 * price_previous

# Calculate the equilibrium price and quantity


def find_equilibrium():
# Set demand equal to supply and solve for P
# 12.4 - 1.2*P = 8.0 - 0.6*P
# Rearranging to find P:
P_star = (12.4 - 8.0) / (1.2 - 0.6)
Q_star = demand(P_star) # Use the demand equation to find Q
return P_star, Q_star

# Find the equilibrium price and quantity


P_star, Q_star = find_equilibrium()

# Number of periods (iterations)


periods = 10

# Initialize lists to store price and quantity values for each period
P0 = 1.0 # Initial price
prices = [P0]
quantities = [demand(P0)]

# Compute price and quantity for each period


for t in range(1, periods):
price_previous = prices[t - 1]
quantity_demanded = demand(price_previous)
prices.append(supply(price_previous)) # Next price from supply
quantities.append(quantity_demanded) # Quantity from demand

# Plotting
fig, ax = plt.subplots(figsize=(10, 8)) # Adjusted figure size

# Plot demand and supply curves


price_range = np.linspace(0, 10, 100)
demand_curve = demand(price_range)
supply_curve = [supply(p) for p in price_range]
ax.plot(demand_curve, price_range, label='Demand', color='blue',
linewidth=2)
ax.plot(supply_curve, price_range, label='Supply', color='orange',
linewidth=2)

# Add Cobweb Path and Intersection Points


cobweb_prices = [P0]
cobweb_quantities = [demand(P0)]
for t in range(1, periods):
cobweb_prices.append(prices[t])
cobweb_quantities.append(demand(prices[t]))

# Plot cobweb lines


ax.plot([cobweb_quantities[-2], cobweb_quantities[-1]],
[cobweb_prices[-2], cobweb_prices[-2]], 'r--') # Horizontal
ax.plot([cobweb_quantities[-1], cobweb_quantities[-1]],
[cobweb_prices[-2], cobweb_prices[-1]], 'r--') # Vertical

# Highlight intersection points with black circles


ax.plot(cobweb_quantities[-1], cobweb_prices[-2], 'ko', markersize=5)

# Plot equilibrium point


ax.plot(Q_star, P_star, 'go', label=f'Equilibrium Point ({Q_star:.2f},
{P_star:.2f})')

# Set labels and title


ax.set_title('Cobweb Model')
ax.set_xlabel('Quantity')
ax.set_ylabel('Price')
ax.legend()
ax.grid(True)

# Show the plot


plt.tight_layout()
plt.show()
Graph:

You might also like