Connects to: Principles Ch. 11 (consumption), Ch. 25 (OLG), Ch. 27 (RBC)
Most policy models, DSGE models, and estimation exercises operate in discrete time. The reasons are practical: macroeconomic data arrive at quarterly or monthly intervals; calibration targets are sample moments computed from those data; and the numerical algorithms used for estimation — particle filters, MCMC samplers, value function iteration on finite grids — are inherently discrete.
This part develops the discrete-time parallel to Part III. Where Part III deployed differential equations, phase planes, and Pontryagin’s maximum principle, this part uses difference equations, dynamic programming, and Bellman’s principle of optimality. Every result has a direct continuous-time analogue; spotting the correspondence — , stability condition , the Hamiltonian the Bellman equation — is the intellectual thread connecting the two parts.
Chapter 14 develops the theory of difference equations systematically, solving the cobweb model and the Samuelson multiplier–accelerator in closed form, and deriving the full stability diagram in parameter space. Chapter 15 builds dynamic programming from the ground up — the Bellman equation, the contraction mapping theorem, value function iteration (VFI), and the Howard policy improvement algorithm — applying them to the buffer-stock consumption model. Chapter 16 solves the Diamond (1965) OLG model in discrete time, deriving dynamic efficiency conditions and analyzing PAYG social security. Chapter 17 assembles the full stochastic RBC model as a recursive competitive equilibrium and solves it via VFI over the state space, computing the second moments used for calibration evaluation.
These four chapters are the computational foundation of Part VII. The reader who understands VFI, the Blanchard–Kahn counting rule, and the recursive competitive equilibrium definition has the tools to understand every step of the DSGE pipeline.
Chapter 14: Difference Equations in Macroeconomics¶
The Cobweb Model and Inventory Cycles
“In discrete time, every model is an iterated map. The question is whether that map converges, oscillates, or explodes — and the eigenvalues of the linearized system give the answer.”
Cross-reference: Principles Ch. 6 (time-series properties of macro data); Ch. 17 (goods market, inventory adjustment model) [P:Ch.6, P:Ch.17]
14.1 Motivating Examples: Why Difference Equations Arise in Macroeconomics¶
Three canonical macroeconomic models generate difference equations naturally.
The inventory adjustment model [P:Ch.17.1]: firms target an inventory stock proportional to expected demand. If actual inventories differ from the target, firms partially adjust: , . With output determining income and demand: , a first-order linear difference equation.
The cobweb model: agricultural supply decisions take one period to implement. Farmers plant based on last period’s price; consumers buy at the current clearing price. The resulting price dynamics: , where and are supply and demand slopes.
The multiplier–accelerator [P:Ch.8]: Samuelson’s (1939) model combines the Keynesian income multiplier with an investment accelerator, generating a second-order difference equation that can produce oscillatory business cycles.
These three models span the key structural features of macroeconomic difference equations: first-order monotone dynamics, first-order oscillatory dynamics (cobweb with ), and second-order complex dynamics (multiplier-accelerator with complex eigenvalues). The theory developed below characterizes all three.
14.2 First-Order Linear Difference Equations: Complete Solution¶
Definition 14.1 (First-Order Linear Difference Equation). A first-order linear difference equation has the form:
with given initial condition .
14.2.1 Homogeneous Solution¶
For : has solution .
Stability: iff ; diverges iff ; cycles between iff ; for all iff .
14.2.2 Particular Solution and General Solution¶
For : the steady state is . The general solution:
The term is the transient (decays iff ); is the steady state (particular solution).
Convergence:
| Condition | Behavior |
|---|---|
| Monotone convergence to | |
| Oscillatory convergence (alternating signs) to | |
| Monotone divergence | |
| Oscillatory divergence | |
| No finite steady state; (drift) | |
| Oscillation between and |
14.2.3 The Cobweb Model: First-Order Dynamics¶
In the cobweb model, supply is based on last period’s price: , . Demand: , . Market clearing :
This is a first-order difference equation with and . Stability requires , i.e., : supply must be more inelastic than demand.
Rational expectations correction: If farmers correctly anticipate the equilibrium price for all , there are no cobweb dynamics — markets clear immediately at the steady state. The cobweb arises only under naive expectations (). This motivates the rational expectations assumption: if agents understand the model, they eliminate self-fulfilling oscillations [P:Ch.16].
14.3 Second-Order Linear Difference Equations¶
Definition 14.2 (Second-Order Linear Difference Equation). A second-order linear difference equation has the form:
with initial conditions and . The characteristic equation is:
Theorem 14.1 (General Solution — Second-Order). Let be the roots of the characteristic equation and (assuming ).
Case 1: Distinct real roots ().
Case 2: Repeated root (, ).
Case 3: Complex conjugate roots (), .
where and .
Proof of Case 3. Write and . Then , and the real general solution combines and with conjugate coefficients, giving the stated form.
Stability for second-order equations: The system is stable (both roots with ) iff:
These are necessary and sufficient. For complex roots (), stability reduces to , i.e., .
14.4 The Multiplier–Accelerator: Second-Order Dynamics in Full¶
Definition 14.3 (Samuelson Multiplier–Accelerator). Samuelson’s (1939) model:
Substituting: , or:
This is a second-order difference equation with and . The steady state .
Characteristic equation: .
Discriminant: ... Let me compute directly: .
Case analysis for business cycle character:
| Region | Eigenvalue type | Dynamic path |
|---|---|---|
| Two distinct real | Monotone approach | |
| Complex conjugates | Oscillatory (cyclical) | |
| Convergent (dampened) cycles | ||
| Neutral oscillation (limit cycle) | ||
| Explosive oscillation |
Theorem 14.2 (Stability Conditions for Multiplier–Accelerator). The Samuelson multiplier-accelerator is stable iff , and generates business cycles (oscillatory path) iff .
Proof. Stability requires (necessary and sufficient for the complex-root modulus to be less than 1). Oscillation requires , i.e., .
The period of oscillation: For complex roots with modulus and argument , the period of one oscillation is periods. With and : , radians, period periods — a business cycle of roughly 3–4 years for quarterly data.
14.5 Systems of Linear Difference Equations¶
Definition 14.4 (State-Space Form). A system of first-order linear difference equations:
where is the state vector, is an exogenous input, is the transition matrix, and is the input matrix.
Theorem 14.3 (Solution of Linear State-Space System). The solution of is:
where is the eigendecomposition. The general solution with inputs is:
Stability: The system is stable iff all eigenvalues of satisfy .
Impulse response: The response at horizon to a unit shock is (the -th column of ). The full IRF sequence decays to zero iff all .
In APL, the IRF at all horizons 0..H-1 is generated in one expression:
⍝ APL — Impulse response function from state-space system
⎕IO←0
A ← 2 2 ⍴ 0.9 0.1 0.0 0.8
B ← 0.5 0.3
H ← 20
⍝ {A+.×⍵} is a monadic function: "Multiply A by the input"
⍝ ⍣⍵ applies that function ⍵ times to the starting vector B
irf ← { ({A+.×⍵}⍣⍵) B } ¨ ⍳ H
⎕← '--- IRF Results (First 5 Horizons) ---'
⎕← ↑ 5 ↑ irf14.6 Worked Example: Full Solution of the Multiplier–Accelerator¶
Setup: , , .
Steady state: .
Characteristic equation: .
Roots: .
Discriminant: → complex roots.
, radians.
Period: periods.
General solution:
Initial conditions: (4% below steady state), (2% below).
From : .
From : .
Verified: The economy oscillates with period ≈ 14 periods (3.5 years quarterly) and dampens at rate — Kydland–Prescott business cycles are calibrated to match such dynamics.
⍝ APL — Multiplier-accelerator simulation and stability diagram
⎕IO←0 ⋄ ⎕ML←1
b ← 0.8 ⋄ v ← 0.8 ⋄ G ← 100
Ystar ← G ÷ 1-b ⍝ steady state = 500
⍝ One-step recursion: Y_t = b(1+v)*Y_{t-1} - bv*Y_{t-2} + G
⍝ State = [Y_{t-1}, Y_t]; step advances to [Y_t, Y_{t+1}]
step ← {
Yprev Ycurr ← ⍵
Ynext ← b×(1+v)×Ycurr - b×v×Yprev + G
Ycurr Ynext}
⍝ Simulate 80 periods from initial conditions
Y0 ← 480 ⋄ Y1 ← 490
path_pairs ← step \ 80 ⍴ ⊂ Y0 Y1 ⍝ scan collects all pairs
Y_path ← {⊃⌽ ⍵}¨ path_pairs ⍝ extract second element (current Y)
⍝ Verify convergence to steady state
Y_path[0] Y_path[39] Y_path[79] ⍝ should trend toward 500
⍝ Stability diagram: 20×20 grid over (b, v) ∈ [0,1]×[0,3]
b_grid ← (⍳20) ÷ 20
v_grid ← (⍳20) × 3 ÷ 20
⍝ Stability: bv < 1
stable_mat ← b_grid ∘.{⍺×⍵ < 1} v_grid ⍝ 20×20 Boolean stability matrix
⍝ Complex roots: b²(1+v)² < 4bv
complex_mat ← b_grid ∘.{(⍺*2)×(1+⍵)*2) < 4×⍺×⍵} v_grid
⍝ Oscillatory and stable = complex_mat AND stable_mat
osc_stable ← stable_mat ∧ complex_mat
⍝ Each region characterised:
⍝ stable_mat ∧ ~complex_mat → monotone convergence
⍝ osc_stable → dampened oscillation (business cycles)
⍝ ~stable_mat ∧ complex_mat → explosive oscillation
⍝ ~stable_mat ∧ ~complex_mat → monotone divergenceimport numpy as np; import matplotlib.pyplot as plt
from matplotlib.colors import ListedColormap
b_vals = np.linspace(0.01, 0.99, 200)
v_vals = np.linspace(0.01, 2.99, 200)
B, V = np.meshgrid(b_vals, v_vals)
stable = B*V < 1
complex_ = B**2*(1+V)**2 < 4*B*V
region = np.zeros_like(B, dtype=int)
region[stable & ~complex_] = 1 # monotone convergence
region[stable & complex_] = 2 # oscillatory convergence (cycles)
region[~stable & complex_] = 3 # explosive oscillation
region[~stable & ~complex_] = 4 # monotone divergence
cmap = ListedColormap(['white','lightblue','steelblue','tomato','salmon'])
plt.figure(figsize=(8,6))
plt.contourf(B, V, region, levels=[-0.5,0.5,1.5,2.5,3.5,4.5], cmap=cmap)
plt.contour(B, V, stable.astype(int), levels=[0.5], colors='black', linewidths=2)
plt.xlabel('MPC (b)'); plt.ylabel('Accelerator (v)')
plt.title('Stability diagram: multiplier-accelerator\n(dark blue = oscillatory convergence = business cycles)')
plt.colorbar(ticks=[0,1,2,3,4], label='Region')
plt.tight_layout(); plt.show()
# Time path simulation
b, v, G = 0.8, 0.8, 100
Y = np.zeros(80); Y[0], Y[1] = 480, 490
for t in range(2, 80):
Y[t] = b*(1+v)*Y[t-1] - b*v*Y[t-2] + G
plt.figure(); plt.plot(Y); plt.axhline(G/(1-b), c='r', ls='--', label='Y*=500')
plt.xlabel('Period'); plt.ylabel('Output'); plt.title('Multiplier-Accelerator Path (b=0.8, v=0.8)'); plt.legend(); plt.show()b, v, G = 0.8, 0.8, 100.0
Ystar = G / (1-b)
# Characteristic roots
p_coef, q_coef = -b*(1+v), b*v
disc = p_coef^2 - 4*q_coef
if disc < 0
r = sqrt(q_coef); theta = acos(-p_coef/(2r))
println("Complex roots: r=$(round(r,digits=3)), θ=$(round(theta,digits=3)), period=$(round(2π/theta,digits=1))")
else
lam = [(-p_coef + sqrt(disc))/2, (-p_coef - sqrt(disc))/2]
println("Real roots: λ₁=$(round(lam[1],digits=3)), λ₂=$(round(lam[2],digits=3))")
end
Y = zeros(80); Y[1], Y[2] = 480.0, 490.0
for t in 3:80
Y[t] = b*(1+v)*Y[t-1] - b*v*Y[t-2] + G
end
println("Y[1]=$(Y[1]), Y[40]=$(round(Y[40],digits=1)), Y[80]=$(round(Y[80],digits=1)), Y*=$(Ystar)")b <- 0.8; v <- 0.8; G <- 100
Ystar <- G/(1-b)
Y <- numeric(80); Y[1] <- 480; Y[2] <- 490
for(t in 3:80) Y[t] <- b*(1+v)*Y[t-1] - b*v*Y[t-2] + G
cat(sprintf("Steady state: %.0f; Y[40]=%.1f; Y[80]=%.1f\n", Ystar, Y[40], Y[80]))
# Period of oscillation
disc <- (b*(1+v))^2 - 4*b*v
if(disc < 0) {
r <- sqrt(b*v); theta <- acos(b*(1+v)/(2*r))
cat(sprintf("Period ≈ %.1f quarters\n", 2*pi/theta))
}
plot(Y, type='l', xlab='Period', ylab='Output', main='Multiplier-Accelerator')
abline(h=Ystar, lty=2, col='red')14.7 Programming Exercises¶
Exercise 14.1 (APL — Cobweb Stability)¶
Write a dfn cobweb ← {alpha beta gamma delta T ← ⍵ ⋄ ...} that simulates periods of the cobweb model starting from an arbitrary price . (a) Verify convergence when and divergence when . (b) Use ∘.{|⍺÷⍵} < 1 to generate a Boolean stability grid over pairs and display it.
Exercise 14.2 — Analytical Period Calculation ()¶
For the multiplier-accelerator with and : (a) compute the oscillation period analytically for each ; (b) determine the range of for which oscillations occur; (c) show that as the period approaches — period-2 oscillations.
Exercise 14.3 — Companion Form Eigenvalues ()¶
Convert the second-order equation to a state-space system with state and companion matrix . (a) Verify that the eigenvalues of equal the roots of the characteristic equation. (b) Show that stability of the companion system () is equivalent to the stability condition .
Exercise 14.4 — Inventory Cycle ()¶
Derive the inventory adjustment model from first principles [P:Ch.17.1]. Let firms target , partially adjust inventories: , and produce . With : (a) derive the difference equation for ; (b) find the stability condition; (c) calibrate with , , and simulate the impulse response to a 10-unit increase in autonomous demand .
14.8 Chapter Summary¶
Key results:
First-order equations have steady state and general solution ; stable iff .
The cobweb model is a first-order equation with ; stable iff supply is more inelastic than demand (); rational expectations eliminate cobweb dynamics entirely.
Second-order equations have solutions characterized by their characteristic roots — real monotone, complex oscillatory, or explosive — with stability requiring and .
The multiplier–accelerator is stable iff and oscillatory (business cycles) iff ; the oscillation period is .
State-space form : stable iff all eigenvalues of satisfy ; IRFs are applied to the shock vector.
In APL: simulation is a scan
step \ T ⍴ ⊂ initial_state; IRFs are{(A⍣⍵)+.×B}¨⍳H; the stability diagram isb_grid ∘.{⍺×⍵ < 1} v_grid.
Next: Chapter 15 — Dynamic Programming for Consumption and Saving