Teodor has lifetime wealth W (in today's coins; all his income already added in at present value) to spend over the periods t = 0, 1, \ldots, T-1. Money he does not spend earns interest r per period (a fraction), so his plan c_0, \ldots, c_{T-1} must satisfy the lifetime budget
He values a plan by its lifetime utility
where the discount factor \beta (beta, with 0 < \beta \le 1) measures patience: a unit of utility next period is worth \beta units now. The best plan satisfies the Euler equation in every period:
(Moving one coin from period t to t+1 costs 1/c_t of utility now and brings \beta (1 + r) / c_{t+1} later; at the best plan that trade neither helps nor hurts.)
Write euler_plan(W, r, beta, T) that returns a tuple (plan, U): the list [c_0, \ldots, c_{T-1}] of the best plan and its lifetime utility (natural logarithm, math.log). Press Run with plot(plan, kind="bar") to see it tilt.
Examples
Input: W = 100, r = 0.1, beta = 0.8, T = 3
Output: ([40.98360656, 36.06557377, 31.73770492], 8.79424663)
Explanation: beta * (1 + r) = 0.88 < 1: impatience beats interest, so consumption falls
by 12 % a period. Spending the same 36.56 every period would give only U = 8.78118.
Input: W = 100, r = 0.25, beta = 0.8, T = 4
Output: ([33.87533875, 33.87533875, 33.87533875, 33.87533875], 10.39897285)
Explanation: beta * (1 + r) = 1 exactly, so the plan is flat.
Input: W = 50, r = 0.1, beta = 0.9, T = 1
Output: ([50.0], 3.91202301)
Constraints
- answers are compared with a tolerance of
1e-6; do not round
Goals
- Use the Euler equation $c_{t+1} = \beta (1 + r)\, c_t$ to tie every period's consumption to the first
- Pin down the first period's consumption with the lifetime budget
- Compare patience $\beta$ with the reward for waiting $1 + r$ to see whether consumption rises or falls