Math Camp
Lecture 9: Dynamic Programming and the Bellman Equation
In many economic problems, the decision maker faces a sequence of choices, each affecting the next. A household that saves today has more to spend tomorrow; a firm that invests today produces more next year. Today’s choice earns a payoff now and changes the situation for every later choice, so the choices at different dates cannot be studied separately. Dynamic programming is a tool for solving such problems.
1 Sequential problems and their recursive form
1.1 The growth problem
Time is discrete, . An agent (decision-maker) starts with a stock of capital . Capital produces output at date , and output is either consumed, , or carried forward as next period’s capital, . The agent values consumption streams by a discounted sum of one-period utilities and solves
The number is the discount factor. The utility function is continuous, strictly increasing, and strictly concave, and is continuous, increasing, and concave with ; both are differentiable on . When we differentiate a value function we assume in addition that as , so that an agent never chooses zero consumption.
Problem (1) is written as a sequential problem: the unknown is the whole sequence of consumptions and capital stocks, , chosen at once. Since , the capital sequence determines the consumption sequence. We can therefore use as the choice at date . Every date has the same structure, drawn in Figure 1.1: The agent inherits the state at date and chooses , earning the current payoff . The transition makes today’s choice tomorrow’s state.
The state is not simply “a variable indexed by .” It is the information inherited from the past that matters for the choices still to be made. In the growth problem, once is known, the feasible choices at date and everything after depend on the past only through : two histories that arrive at the same face the same future. Which sequence of earlier consumptions produced is irrelevant, so it is not part of the state. If instead the payoff at date were , so that yesterday’s consumption changed the value of today’s, then would have to be carried in the state along with . A state must therefore contain all information from the history that affects future feasible choices, payoffs, or transitions.
1.2 The principle of optimality and the Bellman equation
Suppose the agent begins a date with capital and chooses . From tomorrow on the agent faces the same continuation problem as (1), with in place of : the same technology, preferences, and infinite horizon. The highest utility attainable from tomorrow on therefore depends only on .
Definition 1.1 (Value function). The value function assigns to each initial stock the largest lifetime utility attainable from it,
Whenever we write a maximum, we assume that the objective is finite and the maximum is attained. Bounded one-period utility is sufficient for convergence: if for every , every feasible stream has discounted utility of absolute value at most by the geometric-sum calculation of Lecture 8’s Example 3.9. Attainment requires additional conditions supplied by the macroeconomics sequence.
Now split lifetime utility from into today’s payoff and everything after. If today’s choice is , then today yields , and the most that tomorrow and later can yield is , discounted once because it starts one period later. An optimal choice of makes the total as large as possible:
This is the Bellman equation of the growth problem. Its terms correspond to the pieces of Section 1.1:
is the current state;
is the choice, and is the set of feasible choices;
is the current payoff;
today’s choice becomes tomorrow’s state, which is why the same letter appears inside ;
is the continuation value, the value of behaving optimally from tomorrow on;
discounts the continuation value back to today.
The reasoning that produced (2) is Bellman’s principle of optimality: after any feasible first choice, the best continuation is an optimal plan for the problem that starts from the resulting state. In particular, every tail of an optimal plan is optimal from the state reached at that date. Otherwise, replacing the tail by an optimal continuation would raise lifetime utility without changing any earlier payoff.
The unknown in (2) is a function. The equation must hold at every , and the same appears on both sides, once evaluated at and once at . Thus solving the Bellman equation means finding a function that satisfies it at every state. For a fixed and a fixed candidate , the maximization inside the braces is a one-variable problem of the kind solved in Lecture 6. The recursive formulation repeats this one-period choice at every state.
The recursive formulation gives more than an equation for . Under our assumptions, the value function of Definition 1.1 is the unique bounded solution of the Bellman equation when is bounded. Moreover, a feasible capital sequence is optimal for (1) if and only if, at every date, its attains the maximum in (2) at the state . We use these facts without proof; Section 3.2 returns to the uniqueness claim.
1.3 Value function and policy function
Solving (2) produces two objects, and it is important to keep them apart. The first is the value function . The second is the choice that attains the maximum at each state.
Definition 1.2 (Policy function). The policy function assigns to each state the choice that attains the maximum in the Bellman equation,
Under our assumptions the maximizer is unique at every , so is a function; we take this without proof. Consumption then follows from the constraint, . The two functions answer different questions: The policy function describes the agents’s choice at each state and generates the whole optimal path from alone: The Bellman equation determines the value function. Its continuation term values tomorrow’s capital in today’s utility. The sequential problem (1) and the recursive problem (2) generate the same optimal paths; the recursive formulation describes them with a rule rather than a list of numbers.
2 First-order and envelope conditions
The maximization inside the Bellman equation is a one-variable problem. Lecture 6 supplies its first-order condition, and Lecture 8’s envelope theorem gives the derivative of the optimized value. In this section we assume, for , that is differentiable and concave and that the maximizer is interior, , and differentiable in . Standard dynamic-programming results establish these properties under suitable hypotheses; we impose them rather than prove them.
2.1 The first-order condition
Fix and let . The objective in (2) is , and Lecture 6’s interior first-order condition, differentiating in , gives
Since the objective is concave in , the first-order condition is sufficient by Lecture 6’s Theorem 3.2: it locates the maximizer . In words, one more unit of capital carried into tomorrow costs in utility today and is worth , the discounted marginal value of capital tomorrow. At the optimum the two are equal.
To eliminate the unknown derivative from (3), we use the envelope condition.
2.2 The envelope condition and the Euler equation
The Bellman equation defines as an optimized value with parameter . By Lecture 8’s Theorem 2.1, part 1, we hold the choice at its optimum and differentiate the objective only with respect to . The parameter appears only in , so
This is the envelope condition. One more unit of capital today raises output by , and at the margin the extra output is worth whether it is consumed or saved, because the first-order condition has equated the two uses; the response of contributes nothing to first order.
Equation (4) holds at every state, so it holds at tomorrow’s state with tomorrow’s consumption : . Substituting into (3),
where we have restored time subscripts, , , and . This is the Euler equation of the growth problem. Its left side is the utility cost of saving one more unit today. Its right side is the benefit: the unit becomes units of output tomorrow, each worth , discounted once. Substitution has eliminated and left a relation between consumption at adjacent dates and the model’s primitives.
The calculation has three steps that recur throughout macroeconomics:
2.3 The same Euler equation from the sequential problem
We can also derive (5) directly from the sequential formulation. Substitute into (1), so that the objective becomes a function of the capital sequence alone. The variable appears in exactly two terms of the sum, dated and . At an interior optimum, Lecture 6’s first-order condition in the single variable , all other capital stocks held fixed, gives which is (5) after dividing by . The economics is a one-period perturbation: consume one unit less at , carry it forward, and consume the proceeds at ; at an optimum the change in lifetime utility is zero to first order.
The two derivations produce the same condition because the recursive and sequential formulations describe the same problem. The Bellman equation, its first-order condition, and its envelope condition reproduce the intertemporal optimality condition obtained directly from the sequential problem, using a one-period problem with the same form at every state. The Euler equation is a relation between three consecutive capital stocks ; the initial condition pins down one end of the path, and the macroeconomics sequence supplies the condition that pins down the other, the transversality condition. We do not develop the transversality condition in this course.
2.4 Writing down a Bellman equation
Given a new dynamic problem, the procedure is: identify the state, the choice, the payoff, and the transition; then write today’s payoff plus times the value at tomorrow’s state, maximized over today’s choice. The consumption–saving problem also shows how two choices can parameterize the same recursion.
Example 2.1 (Consumption and saving at a fixed interest rate). A consumer holds wealth at the start of date , consumes , and invests the rest at gross return , so that Lifetime utility is , and is given.
State. Wealth . Once is known, nothing about the past matters for the future.
Choice. Consumption .
Payoff. .
Transition. .
The Bellman equation is There is more than one convenient way to parameterize the choice. Since , the consumer may instead choose tomorrow’s wealth : The two equations have the same solution ; the economic problem determines the recursion, and the notation is a matter of convenience. In the growth problem we chose for the same reason: it keeps the continuation value simple.
Under the assumptions of Section 2, the first-order condition in from the first formulation is and the envelope condition, differentiating in the parameter at the optimal , is Applying the envelope condition at tomorrow’s state, , and substituting into the first-order condition gives the Euler equation The consumer equates the marginal utility of a unit consumed today with that of the units it would become tomorrow, discounted. If , consumption is constant over time; if , marginal utility falls and consumption rises. The first-year consumption theory sequence uses this equation as its starting point.
3 Why the recursion works: finite horizons and the fixed point
Finite horizons make the recursive logic explicit because they provide a last date from which to work backward. For an infinite horizon, the contraction mapping theorem determines the value function without a last date.
3.1 Finite horizons and backward induction
Suppose the world ends after date : the agent solves
with no use for capital after date . The value function now depends on the date as well as on the state, because the agent at date has decision dates remaining. Write for the largest utility from date on when the date- state is .
At the last date the problem is trivial. Capital left over is wasted and is increasing, so the agent consumes all output: At date the agent chooses knowing its continuation value, : Once is known, this is a one-variable problem of Lecture 6, and solving it at every gives the function . Then is obtained from in the same way, and so on down to :
Proposition 3.1 (Finite-horizon Bellman recursion). For and every , and a feasible capital sequence solves (6) if and only if at every date its attains the maximum at the state .
Proof (optional). Fix and , and write for the right-hand side of the display. Every feasible plan from date at state begins with some and continues with a feasible plan from date at state , whose utility from on is at most . So every plan earns at most , and . Conversely, let attain the maximum and follow it with an optimal plan from date at state ; that plan exists by induction downward from date , where the optimal plan is to consume everything. The combined plan is feasible and earns , so . The two inequalities give the recursion. The same comparison shows that a plan achieves exactly when its first choice attains the maximum and its continuation is optimal. This proves the biconditional. ◻
Computing in that order is called backward induction: it is Lecture 1’s induction, run from the last date toward the first. Each step is a static problem, and each maximum is attained by the Weierstrass theorem of Lecture 2 when the objective is continuous, since is compact. The principle of optimality is also established by the argument: an optimal plan’s continuation from any date is optimal for the problem starting from the state reached on that date.
Example 3.2 (Two dates of cake eating). Let and . Capital does not reproduce in this special case: is a stock of cake, and the agent divides it between consumption now and cake carried to the next date. Fix an upper bound and take the state space to be , which is invariant because every feasible choice satisfies . Let , so there are two dates. At date the agent consumes everything: At date the recursion gives For the objective is strictly concave and its one-sided slopes at the two endpoints point toward the interior. Its first-order condition is the unique maximizer by Lecture 6’s Theorem 3.1. The agent carries the fraction of the cake to date and consumes the rest. Substituting back gives Thus and are both a constant multiple of .
The pattern continues. If with , the same calculation gives Consequently, As the number of remaining dates grows, increases to , and the fraction carried forward increases to . Section 4 obtains these limits by solving the infinite-horizon problem directly.
3.2 The infinite horizon as a fixed point
With no last date there is no from which to start. Example 3.2 shows the coefficient on and the fraction carried forward approaching limits as dates are added. In a stationary problem, one whose payoff, feasible set, and transition are the same at every date, the infinite-horizon value does not depend on the calendar. The recursion of Proposition 3.1 with is the Bellman equation (2). Whether an infinite-horizon exists, and whether it is unique, is a fixed-point question. Under bounded rewards, a contraction argument on the space of bounded functions answers it.
To state the contraction result, write a stationary problem in general notation. It has a state in a state space , a set of feasible actions at , a reward , a transition , and a discount factor ; the growth problem is the case , , , , and . Table 3.1 lists the correspondence. The Bellman equation is written with a supremum so that it makes sense before anything is known about attainment.
| Object | Growth problem | General stationary problem |
|---|---|---|
| State | capital | |
| Feasible choices | ||
| Current payoff | ||
| Transition | ||
| Bellman equation | ||
| Policy function |
Definition 3.3 (Bellman operator). Let be the set of bounded functions with the sup norm . The Bellman operator sends a candidate value function to the function
The number is the supremum value of a one-period choice at when values tomorrow’s state. The Bellman equation says : the value function is a fixed point of . Backward induction is iteration of , since in Proposition 3.1. The operator is the function-valued version of the map in Lecture 8’s Example 3.9: today’s reward plus times the continuation.
Theorem 3.4 (The Bellman operator is a contraction). Suppose is nonempty for every and there is with whenever . Then maps into , and for all ,
Proof (optional). Every number whose supremum defines lies between and , so for every and . Now fix . For every the definition of the sup norm gives , hence The inequality holds action by action, so it survives the supremum over : . Exchanging and gives the reverse bound, so at every , and taking the supremum over finishes the proof. ◻
The space is complete in the sup norm, a fact we use without proof. The contraction mapping theorem therefore gives three conclusions. The Bellman equation has exactly one bounded solution. Starting from any bounded , even , the iterates converge to it in sup norm, with the worst-case error shrinking by the factor each time. This procedure is called value function iteration. For , the iterate is the value of the problem with dates remaining and no terminal value. Thus the infinite-horizon value is the limit of finite-horizon values, as in Example 3.2. More generally, value iteration can start from any bounded function, and the effect of that starting function vanishes at the geometric rate .
Discounting supplies the contraction modulus . As , the worst-case convergence bound becomes arbitrarily slow; at , Lecture 8’s map has no fixed point when : an undiscounted constant stream of nonzero rewards has no finite value. The theorem also requires a bounded reward. In Example 3.2, and , so the hypothesis holds and the finite-horizon values converge uniformly to the unique bounded fixed point. If instead the state space were all of , the same reward would be unbounded above and this theorem would no longer apply.
4 A Bellman equation solved by hand
Value function iteration is useful for numerical work. When the primitives are special enough, the Bellman equation can be solved analytically by guess and verify: conjecture that has a particular functional form with unknown constants, substitute the conjecture into the Bellman equation, carry out the maximization, and check whether the result has the conjectured form again; if it does, matching constants yields equations for them. The guess proposes a candidate; substitution verifies that the candidate is a fixed point. A separate theorem is still needed to show that this fixed point is the value function and is unique in the relevant class.
Example 4.1 (Square-root cake eating). Continue the cake-eating problem of Example 3.2, with , , and . Given , the agent solves Its Bellman equation is The finite-horizon value functions were multiples of , so we conjecture with and look for a constant that makes the equation hold at every .
The maximization. With the conjecture substituted, the objective is strictly concave in . For its unique maximizer is interior and satisfies so For , the only feasible choice is , which the same formula gives.
The verification. Substituting the maximizer back, the right-hand side of the Bellman equation becomes The conjectured form is preserved. Matching the coefficient on gives
The value and policy. The value function and its implied policy and consumption are therefore The agent carries the fixed fraction of the remaining cake to the next date. These are the limits found in Example 3.2. The optimal stock path is , so the remaining cake converges to zero.
Substituting the policy into the Bellman equation verifies the solution directly:
The Euler check. Since and , Finally, is bounded on and the reward is bounded by . The contraction theorem therefore shows that this fixed point is the unique bounded solution of the Bellman equation, and value function iteration from the finite-horizon problems converges to it.