ArticleslgStudy

mathematics

Dynamic programming

Dynamic programming is a mathematics topic covered in the lgStudy science library. This page brings together a partial reference excerpt, illustrations, worked examples, real-world applications and a short study plan, so you can understand Dynamic programming rather than just read about it. In short: Dynamic programming (DP) is both a mathematical optimization method and an algorithmic paradigm. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, such as aerospace engineering and economics.

Dynamic programming — main illustration
Dynamic programming — illustration

Key takeaways

  • Dynamic programming belongs to mathematics; place it in that map before memorising details.
  • Learn the definition first, then one example that makes the definition concrete.
  • Connect Dynamic programming to a quantity you can measure, compute or draw — that is where exam questions come from.
  • Reproduce the core statement of Dynamic programming from memory before moving on to harder problems.

Reference excerpt

Dynamic programming (DP) is both a mathematical optimization method and an algorithmic paradigm. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, such as aerospace engineering and economics. In both contexts, it refers to simplifying a complex problem by breaking it down into simpler subproblems in a recursive manner. While some decision problems cannot be taken apart this way, decisions that span several points in time do often break apart recursively. Likewise, in computer science, if a problem can be solved optimally by breaking it into subproblems and then recursively finding the optimal solutions to the subproblems, then it is said to have optimal substructure. If subproblems can be nested recursively inside larger problems, so that dynamic programming methods are applicable, then there is a relation between the value of the larger problem and the values of the subproblems. In the optimization literature, this relationship is called the Bellman equation.

Overview

Mathematical optimization In terms of mathematical optimization, dynamic programming usually refers to simplifying a decision by breaking it down into a sequence of decision steps over time. This is done by defining a sequence of value functions V1, V2, ..., Vn taking y as an argument representing the state of the system at times i from 1 to n. The definition of Vn(y) is the value obtained in state y at the last time n. The values Vi at earlier times i = n −1, n − 2, ..., 2, 1 can be found by working backward, using a recursive relationship called the Bellman equation. For i = 2, ..., n, Vi−1 at any state y is calculated from Vi by maximizing a simple function (usually the sum) of the gain from a decision at time i − 1 and the function Vi at the new state of the system if this decision is made. Since Vi has already been calculated for the needed states, the above operation yields Vi−1 for those states. Finally, V1 at the initial state of the system is the value of the optimal solution. The optimal values of the decision variables can be recovered, one by one, by tracking back the calculations already performed.

Control theory In control theory, a typical problem is to find an admissible control 𝐮∗ which causes the system 𝐱˙(t)=𝐠(𝐱(t),𝐮(t),t) to follow an admissible trajectory 𝐱∗ on a continuous time interval t0≤t≤t1 that minimizes a cost function

J=b(𝐱(t1),t1)+∫t0t1f(𝐱(t),𝐮(t),t)dt The solution to this problem is an optimal control law or policy 𝐮∗=h(𝐱(t),t), which produces an optimal trajectory 𝐱∗ and a cost-to-go function J∗. The latter obeys the fundamental equation of dynamic programming:

−Jt∗=min𝐮{f(𝐱(t),𝐮(t),t)+Jx∗𝖳𝐠(𝐱(t),𝐮(t),t)} which is a partial differential equation known as the Hamilton–Jacobi–Bellman equation, in which Jx∗=∂J∗∂𝐱=[∂J∗∂x1 ∂J∗∂x2 … ∂J∗∂xn]𝖳 and Jt∗=∂J∗∂t. One finds that minimizing 𝐮 in terms of t, 𝐱, and the unknown function Jx∗ and then substitutes the result into the Hamilton–Jacobi–Bellman equation to get the partial differential equation to be solved with boundary condition J(t1)=b(𝐱(t1),t1). In practice, this generally requires numerical techniques for some discrete approximation to the exact optimization relationship. Alternatively, the continuous process can be approximated by a discrete system, which leads to a following recurrence relation analog to the Hamilton–Jacobi–Bellman equation:

Jk∗(𝐱n−k)=min𝐮n−k{f̂(𝐱n−k,𝐮n−k)+Jk−1∗(𝐠̂(𝐱n−k,𝐮n−k))} at the k-th stage of n equally spaced discrete time intervals, and where f̂ and 𝐠̂ denote discrete approximations to f and 𝐠. This functional equation is known as the Bellman equation, which can be solved for an exact solution of the discrete approximation of the optimization equation.

Example from economics: Ramsey's problem of optimal saving

In economics, the objective is generally to maximize (rather than minimize) some dynamic social welfare function. In Ramsey's problem, this function relates amounts of consumption to levels of utility. Loosely speaking, the planner faces the trade-off between contemporaneous consumption and future consumption (via investment in capital stock that is used in production), known as intertemporal choice. Future consumption is discounted at a constant rate β∈(0,1). A discrete approximation to the transition equation of capital is given by

kt+1=ĝ(kt,ct)=f(kt)−ct where c is consumption, k is capital, and f is a production function satisfying the Inada conditions. An initial capital stock k0>0 is assumed. Let ct be consumption in period t, and assume consumption yields utility u(ct)=ln⁡(ct) as long as the consumer lives. Assume the consumer is impatient, so that he discounts future utility by a factor b each period, where 0<b<1. Let kt be capital in period t. Assume initial capital is a given amount k0>0, and suppose that this period's capital and consumption determine next period's capital as kt+1=Akta−ct, where A is a positive constant and 0<a<1. Assume capital cannot be negative. Then the consumer's decision problem can be written as follows:

max⁡∑t=0Tbtln⁡(ct) subject to kt+1=Akta−ct≥0 for all t=0,1,2,…,T Written this way, the problem looks complex, because it involves solving for all the choice variables c0,c1,c2,…,cT. (The capital k0 is not a choice variable—the consumer's initial capital is taken as given.) The dynamic programming approach to solve this problem involves breaking it apart into a sequence of smaller decisions. To do so, we define a sequence of value functions Vt(k), for t=0,1,2,…,T,T+1 which represent the value of having any amount of capital k at each time t. There is (by assumption) no utility from having capital after death, VT+1(k)=0. The value of any quantity of capital at any previous time can be calculated by backward induction using the Bellman equation. In this problem, for each t=0,1,2,…,T, the Bellman equation is

… excerpt ends here. Continue reading the full article.

Illustrations

Dynamic programming: Figure 1. Finding the shortest path in a graph using optimal substructure; a straight line indicates a single edge; a wavy line indicates a shortest path between the two vertices it connects (among other paths, not shown, sharing the same two vertices); the bold line is the overall shortest path from start to goal.
Figure 1. Finding the shortest path in a graph using optimal substructure; a straight line indicates a single edge; a wavy line indicates a shortest path between the two vertices it connects (among other paths, not shown, sharing the same two vertices); the bold line is the overall shortest path from start to goal.
Dynamic programming: Figure 2. The subproblem graph for the Fibonacci sequence. The fact that it is not a tree indicates overlapping subproblems
Figure 2. The subproblem graph for the Fibonacci sequence. The fact that it is not a tree indicates overlapping subproblems
Dynamic programming: A model set of the Towers of Hanoi (with 8 disks)
A model set of the Towers of Hanoi (with 8 disks)
Dynamic programming: An animated solution of the Tower of Hanoi puzzle for T(4,3)
An animated solution of the Tower of Hanoi puzzle for T(4,3)

Worked examples

Example 1 — a first encounter with Dynamic programming

Start with the simplest possible case. Write down what Dynamic programming claims or describes in one sentence, then invent the smallest concrete situation in which that sentence is true. In mathematics, the smallest case is usually a single object, a single equation or a single measurement. Check that every symbol or term in your sentence has a meaning in that case.

Example 2 — changing one variable

Take the situation from Example 1 and change exactly one quantity: double it, halve it, or set it to zero. Predict what should happen to Dynamic programming before you calculate. Comparing your prediction with the result is the fastest way to find out whether you understand the idea or only the words.

Example 3 — an exam-style question

Typical questions about Dynamic programming ask you to (a) state it precisely, (b) apply it to given data, and (c) explain a limitation. Practise writing all three answers in under five minutes; the third part is what separates a full-mark answer from an average one.

Applications of Dynamic programming

In research
Dynamic programming appears in mathematics research whenever the underlying quantities have to be modelled precisely. Papers usually cite it as a starting assumption and then explore where it breaks down.
In technology and industry
Engineering practice reuses Dynamic programming in design rules, simulations and safety margins. Knowing the idea lets you read a specification sheet and understand why the numbers look the way they do.
In the classroom
Dynamic programming is common in secondary-school and first-year university syllabi. It links to neighbouring topics Dynamic programming, Equations, Optimal control, so understanding it makes those chapters shorter.
In everyday life
Look for Dynamic programming outside the textbook — in sport, cooking, traffic, electronics or the sky above you. An example you found yourself is remembered far longer than one you were given.
Ask Teacher Smith questions about this articleOpens your AI tutor with a question about “Dynamic programming” →

How to study Dynamic programming in 20 minutes

  1. Read the reference excerpt below once, without taking notes.
  2. Close the page and write down what Dynamic programming means in your own words.
  3. Compare your version with the excerpt and mark what you missed.
  4. Work through the three examples above with pen and paper.
  5. Explain Dynamic programming out loud to somebody else — or to Teacher Smith in the lgStudy chat.

Frequently asked questions

What is Dynamic programming in simple terms?

Dynamic programming (DP) is both a mathematical optimization method and an algorithmic paradigm. The method was developed by Richard Bellman in the 1950s and has found applications in numerous fields, such as aerospace engineering and economics.

Why does Dynamic programming matter?

Because it connects several mathematics ideas at once: it gives you a definition you can apply, a quantity you can calculate, and a way to check whether a result is plausible.

How should I study Dynamic programming?

Read the excerpt, restate it from memory, then work through the examples and applications listed on this page. The five-step study plan above takes about twenty minutes.

What does this page cover?

It gives you a compact reference excerpt plus original lgStudy explanations, examples, applications and study material on Dynamic programming.

Tags

  • Dynamic programming
  • Equations
  • Optimal control
  • Optimization algorithms and methods
  • Systems engineering

Keep exploring