Economists in Varne want to know how much output is demanded at each price level P. Output Y is in millions of base-year crowns per year, the interest rate r is a fraction (5 % is 0.05), T is a fixed tax, G government purchases and M the money supply, which stays fixed:
- goods market: output equals planned spending, Y = C + I + G, with consumption C = c_0 + c_1 \, (Y - T) and investment I = i_0 - i_1 \, r;
- money market: the real money supply equals real money demand, \dfrac{M}{P} = k \, Y - h \, r.
For a given P, the IS-LM equilibrium is the one pair (Y, r) that clears both markets. Doing this for every P traces the aggregate demand (AD) curve: equilibrium output as a function of the price level. In this problem the model has no floor on r or I: use the equations as they stand even if a rate comes out negative.
Write ad_curve(e, prices, Y_n) that returns a tuple (rows, P_n):
rows: one pair(Y, r)for each price level inprices, in the same order (the economy's owne["P"]is not used);P_n: the positive price level at which equilibrium output equalsY_n, orNoneif no positive price level gives it.
The tests build each economy with the helper economy(c0, c1, T, i0, i1, G, k, h, M, P), which returns the dict {"c0": c0, "c1": c1, "T": T, "i0": i0, "i1": i1, "G": G, "k": k, "h": h, "M": M, "P": P}; you may use it too.
Collect the outputs in a list ys and press Run with plot(ys, prices) to draw the AD curve with output across and the price level up.
Examples
Input: e = economy(100, 0.75, 100, 300, 2000, 200, 0.5, 4000, 1300, 2), prices = [1.6, 2, 2.5], Y_n = 1600
Output: ([(1862.5, 0.0296875), (1700.0, 0.05), (1570.0, 0.06625)], 2.3636363636363638)
Explanation: at P = 2.5 the real money supply is 520; the two markets clear at Y = 1570,
r = 0.06625. Output is 1600 at P = 1300 / 550.
Input: e = economy(100, 0.75, 100, 300, 2000, 200, 0.5, 4000, 1300, 2), prices = [4], Y_n = 1000
Output: ([(1375.0, 0.090625)], None)
Explanation: however high prices go, output stays above 1050 in this economy.
Constraints
- answers are compared with a tolerance of
1e-6; do not round
Goals
- Recompute the IS-LM equilibrium for each price level to trace aggregate demand
- Explain why demand falls as prices rise through the real money supply
- Invert aggregate demand to find the price level that gives a stated output