Courses › Graduate Macroeconomic Theory
Dynamic programming
Turning a plan over many periods into a recursion: state and control variables, the Bellman equation, contraction mappings, guess-and-verify, value function iteration, and the cake-eating problem.
The crash course introduced the Bellman equation through cake eating. This module turns that sketch into a working method. Dynamic programming replaces a choice of an entire infinite plan with a much smaller problem: choose today’s action, knowing that tomorrow you will again behave optimally from wherever you land.
You will see how to set up a problem in terms of states and controls, why the Bellman operator is a contraction, how to solve problems exactly by guessing the form of the value function, how to derive the Euler equation from the Bellman equation, and how computers solve the problems we cannot solve by hand. The method is the backbone of Modules 3 to 11.
By the end of this module you will be able to
- Solve finite-horizon problems by backward induction and state the principle of optimality.
- Write a Bellman equation with state, control and transition, and derive the Euler equation from it using the envelope condition.
- Explain Blackwell’s conditions and use the contraction property to bound the error of value function iteration.
- Solve the cake-eating problem by guess and verify, with log and CRRA utility.
- Set up a stochastic dynamic program, such as the job search model, and find a reservation wage.
What this module covers
- From plans to recursion
- The Bellman equation
- Contraction mappings and value function iteration
- Guess and verify
- Uncertainty and numerical methods
- Problem set with step-by-step solutions
- Module quiz
Lesson 2.1 Free lesson
From plans to recursion
Many economic decisions are plans: how much of a paycheque to spend this month and how much to keep, how to draw down savings in retirement, when to accept a job offer. The direct approach chooses the whole sequence at once. For a cake (or savings account) of size W0 eaten over periods 0, 1, …, T, the sequence problem is
Here β between 0 and 1 is the discount factor: a util next period is worth β utils today. With few periods we can solve this by working backward, which is the heart of dynamic programming.
Worked example: Three periods of cake, solved backward
Take u(c) = ln c, β = 0.9 and W0 = $100 to spend over periods 0, 1 and 2.
Period 2 (last): nothing is left to save for, so eat whatever remains: c2 = W2.
Period 1: choose c1 to maximize ln c1 + 0.9 ln(W1 − c1). The first-order condition 1/c1 = 0.9/(W1 − c1) gives c1 = W1/1.9.
Period 0: the same logic with two periods to go gives c0 = W0/(1 + 0.9 + 0.81) = 100/2.71 = $36.90. Then W1 = $63.10, c1 = 63.10/1.9 = $33.21 and c2 = $29.89.
Each period’s consumption is 0.9 times the previous one, and with T periods left the share eaten is 1/(1 + β + … + βT). As the horizon grows without limit, that share tends to 1 − β = 10%: the infinite-horizon rule from the crash course.
Backward induction works because of Bellman’s principle of optimality: an optimal plan has the property that, whatever the first decision, the remaining decisions are optimal for the situation that first decision creates. So we never need to reconsider the past; we only need the best continuation from each possible situation.
Why recursion matters
With an infinite horizon there is no last period to start from. But the problem looks the same every period: facing a cake of size W, you want to do the best you can from here on. The only thing that differs between dates is the size of the cake. That observation turns an infinite sequence of choices into one equation in one unknown function, the Bellman equation of Lesson 2.
Common mistake
Treating discounting as irrational. β < 1 only says a util today counts more than a util tomorrow. It may reflect impatience, a chance of not being around to enjoy the future, or simply a convenient way to keep infinite sums finite.
Key ideas
- A sequence problem chooses an entire plan; dynamic programming chooses one decision at a time.
- Backward induction solves finite problems from the last period to the first.
- The principle of optimality: the rest of an optimal plan is optimal from wherever it starts.
- With log utility, the share of wealth eaten tends to 1 − β as the horizon grows.
Practice questions: Dynamic programming
Try these, then open each answer to check your work.
- 1.In a dynamic program, the state variable is
- the choice made today that maximizes the reward
- everything inherited from the past that matters for the future
- the discount factor applied to future rewards
- the reward earned in the current period
Show answer
Answer: B. The state summarizes what is inherited and relevant for future payoffs; the control is chosen.
- 2.With log utility and β = 0.9, an infinite-horizon cake eater with $200 eats this period
- $10
- $20
- $90
- $180
Show answer
Answer: B. c = (1 − β)W = 0.1 × 200 = $20.
- 3.Which pair of conditions combines into the Euler equation u′(c) = β(1 + r)u′(c′)?
- The first-order condition and the envelope condition
- Monotonicity and discounting
- The transversality condition and the budget
- Completeness and transitivity
Show answer
Answer: A. The FOC gives u′(c) = βV′(a′) and the envelope condition gives V′(a′) = (1 + r)u′(c′).
Problems with step-by-step solutions
- 4.With u = ln c, β = 0.8 and a cake of $100 to be eaten over two periods (0 and 1), find c0 and c1.
Show step-by-step solution
- In period 1 eat everything left: c1 = 100 − c0.
- Maximize ln c0 + 0.8 ln(100 − c0): 1/c0 = 0.8/(100 − c0), so c0 = 100/1.8 ≈ $55.56.
- c1 ≈ $44.44, and c1/c0 = 0.8 = β.
- 5.With log utility and β = 0.95, what share of the cake is eaten in period 0 when there are 3 periods in total, and in the infinite-horizon limit?
Show step-by-step solution
- With 3 periods the share is 1/(1 + β + β2) = 1/(1 + 0.95 + 0.9025) = 1/2.8525 ≈ 35.1%.
- Infinite horizon: 1 − β = 5%.
Get the full module
The complete module adds every lesson, interactive graphs, a full problem set with step-by-step solutions, and a quiz. The academy opens in January 2027: join the waitlist for the founding price (lifetime access for $179).
Join the waitlist Try a full module free
More practice: free practice questions for this course.