The port of Calloway is modelled with a consumption function and fixed investment, government purchases and taxes. Equilibrium output Y (millions of crowns per year) satisfies
where c1 (with 0 <= c1 < 1) is the marginal propensity to consume. The spending multiplier is the change in equilibrium output per one-crown change in G (all else fixed).
Over a few years the council and the town change their spending, one item at a time: each change is a pair (what, amount) where what is "G" (government purchases), "I" (planned investment) or "c0" (autonomous consumption), and amount is added to it (negative amounts are cuts). Changes add up: the second one comes on top of the first.
Write ripples(c1, changes) that returns a tuple (multiplier, totals): the spending multiplier, and a list with the total change in equilibrium output since the start after each change, in order. You are not told the starting levels of c0, I, G, T; you do not need them.
Examples
Input: c1 = 0.75, changes = [("G", 10), ("I", -5), ("c0", 2.5)]
Output: (4.0, [40.0, 20.0, 30.0])
Explanation: with c1 = 0.75 each crown of new spending raises equilibrium output by 4.
The new quay (+10 of G) adds 40; the investment cut takes 20 away again; the extra
2.5 of autonomous consumption adds 10.
Input: c1 = 0, changes = [("G", 7)]
Output: (1.0, [7.0])
Constraints
- answers are compared with a tolerance of
1e-6; do not round
Goals
- Derive the spending multiplier from the equilibrium condition
- Predict the change in equilibrium output from a change in autonomous spending
- Accumulate several changes without knowing the starting levels