Producing Last Year's Demand

dynamic adjustment · simulation · convergence · equilibrium · tolerance

Firms in the valley of Ostry cannot see demand in advance, so each year they produce what buyers planned to spend last year. Output in year t+1 is planned spending at year t's output:

Y_{t+1} = c_0 + c_1 \, (Y_t - T) + I + G

with a fixed tax T, planned investment I, government purchases G, and a marginal propensity to consume c1 with 0 <= c1 < 1 (millions of crowns per year). Year 0's output is Y0.

The equilibrium output Y^* is the output at which planned spending equals output, so that Y_{t+1} = Y_t.

Write catch_up(c0, c1, I, G, T, Y0, tol) that returns a tuple (years, Y): the first year t \ge 0 in which output is within tol of the equilibrium, |Y_t - Y^*| \le tol (exactly tol away counts as within), and that year's output Y_t. If Y0 is already within tol, the answer is (0, Y0).

Collect the outputs in a list and press Run with plot(path) to watch the path approach Y^*.

Examples

Input:  c0 = 50, c1 = 0.5, I = 100, G = 50, T = 100, Y0 = 220, tol = 10
Output: (3, 290.0)
Explanation: the equilibrium is 300. Output goes 220, 260, 280, 290: the gap 80 halves
each year to 40, 20, 10, and 10 is within the tolerance.

Input:  c0 = 40, c1 = 0.8, I = 60, G = 100, T = 50, Y0 = 0, tol = 1
Output: (30, 799.0096479685718)

Constraints

  • answers are compared with a tolerance of 1e-6; do not round

Goals

  • Simulate output that follows planned spending with a one-period lag
  • Stop a simulation once it is within a tolerance of the equilibrium
  • See the gap to equilibrium shrink by the factor `c1` each period
Starting Python…