The island of Vessa keeps track of three numbers each year t: the money supply M_t (millions of shells), the velocity V_t (how many times a year an average shell is spent) and real output Y_t (millions of base-year shells of goods). The quantity equation links them to the price level P_t:
M_t \, V_t = P_t \, Y_t
Total spending (left) equals the value of what is sold (right). Inflation in year t is the growth of the price level, \pi_t = P_t / P_{t-1} - 1. A popular shortcut adds growth rates: \pi_t \approx g_M + g_V - g_Y, where g_X = X_t / X_{t-1} - 1 is the growth rate of X from year t - 1 to year t.
Write quantity_inflation(M, V, Y, target) that returns a tuple (pairs, needed):
pairs: for each yeart = 1, 2, ...of the data, the pair(exact, approx): inflation from the quantity equation, and the shortcut g_M + g_V - g_Y;needed: the money growth rate for the year after the data that makes inflation exactlytarget, if velocity and output grow in that year at the same rates as in the last year of the data.
All rates are fractions (2 % is 0.02).
Examples
Input: M = [500, 550, 605], V = [4, 4, 4.2], Y = [1000, 1030, 1060.9], target = 0.02
Output: ([(0.0679612, 0.07), (0.1213592, 0.12)], 0.0005714) (rounded here)
Explanation: in year 1 money grows 10 %, velocity 0 %, output 3 %:
prices go from 500 * 4 / 1000 = 2 to 550 * 4 / 1030 = 2.1359223, up 6.80 %.
In year 2 velocity also grows 5 %. If it keeps doing so while output grows 3 %,
money may grow only 1.02 * 1.03 / 1.05 - 1 = 0.0571 % for 2 % inflation.
Input: M = [800, 1600], V = [5, 5], Y = [2000, 2100], target = 0.03
Output: ([(0.9047619, 0.95)], 0.0815) (rounded here)
Constraints
- answers are compared with a tolerance of
1e-6; do not round
Goals
- Compute the price level from the quantity equation $M V = P Y$
- Turn growth rates of money, velocity and output into inflation, exactly and approximately
- Solve the quantity equation in growth form for the money growth that hits a target