Learn
Lesson · Dynamic Programming and Sequential Decisions · No last period

Value Iteration and the Fixed Point

Every table on this course has been filled from the end. Take the end away and the recursion has no base case — but the value still satisfies an equation: what a state is worth is its reward plus a discounted average of what the states it leads to are worth. That is v = r + γPv, and it is a linear system. Row reduction solves it exactly. Value iteration, which is the same map applied over and over from zero, approaches it and never gets there, and the denominators make the difference visible in a way that decimals cannot.

no last period, so no base case: v = r + gamma P v is an EQUATION, not a recursion rearranged: (I - gamma P) v = r, a linear system solved by row reduction P = [1/2 1/2 ; 1/4 3/4], r = (1, 3), gamma = 1/2: v = 22/7 and 38/7 check: r + gamma P v - v = 0 exactly, in every row value iteration from zero reaches 3.14171782 after 12 steps, against 22/7 its denominator grows from 1 digit to 10 over those 12 steps, and never stops
One equation, two ways at it, and the check that separates them

Core ideas

What this lesson establishes

Three ideas: why the recursion stops working, what replaces it, and what the iteration is actually doing while it fails to arrive.

1

Without a last period there is no base case, so there is no recursion

Vₜ was always defined from Vₜ₊₁, and the chain terminated at V_T = 0. Remove the horizon and that chain has no end to hang from. What survives is the self-consistency the values must satisfy: v(i) = r(i) + γ Σⱼ P(i,j) v(j) for every state at once. That is not a rule for computing v; it is a condition v obeys, and finding v means solving it.

2

The discount is what makes the equation have one answer

With γ = 1 the totals would generally be infinite and the equation would have many solutions or none. With 0 ≤ γ < 1 the matrix I − γP is invertible for every stochastic P, so there is exactly one v. The discount is doing mathematical work as well as modelling work, and a reader who treats it purely as a preference about the future is missing why it is there.

3

Value iteration is the same map applied repeatedly, and it converges without arriving

Start at v₀ = 0 and apply v ← r + γPv. Each step replaces the error vector by γP times itself, so the error shrinks by a factor tending to γ a step and the values reach the fixed point at no finite step. In exact arithmetic this is not a rounding story: every iterate is a rational with a denominator one power of γ's denominator larger than the last, and the fixed point 22/7 is not among them.

The material

An equation instead of a recursion, and two ways to meet it

Where the base case went, what the equation is, and what the iteration is accumulating while it approaches the answer.

Definition · The discounted value of a policy

Fix a transition matrix P with rows summing to 1, a reward r(i) earned on each visit to state i, and a discount factor γ with 0 ≤ γ < 1. The value v(i) is the expected total of r earned from state i onward, with a reward k steps away counted at γᵏ of its face value.

It satisfies v = r + γPv, equivalently (I − γP)v = r. Since I − γP is invertible for every stochastic P when γ < 1, that system has exactly one solution.

Two states will do. Let P send the first state to each of the two with probability one half, and the second to the first with probability one quarter and to itself with three quarters; let the rewards be 1 and 3, and let the discount be one half. Writing (I − γP)v = r out gives two equations in two unknowns, and row reduction solves them in four operations.

P = [ 1/2 1/2 ; 1/4 3/4 ] r = ( 1 , 3 ) gamma = 1/2 (I - gamma P) v = r: 3/4 v1 - 1/4 v2 = 1 -1/8 v1 + 5/8 v2 = 3 row reduction gives v1 = 22/7 v2 = 38/7 put them back in: 3/4 (22/7) - 1/4 (38/7) = 66/28 - 38/28 = 28/28 = 1 exactly -1/8 (22/7) + 5/8 (38/7) = -22/56 + 190/56 = 168/56 = 3 exactly so r + gamma P v - v = 0 in both rows, with nothing rounded

That last line is the whole reason for exact arithmetic on this page. A decimal solution would give a residual of something like 1e−16, which is indistinguishable from a small error in the solve, and the claim “this is the fixed point” would be unverifiable on the page. As fractions the residual is zero, and the reader can check the two lines above by hand.

What value iteration does instead

Start at zero and apply the map. v₁ is just r, which is (1, 3). v₂ is (2, 17/4). Then (41/16, 155/32), then (365/128, 1315/256), and so on. Each step replaces the gap by γP times itself, so the ratio settles to γ a step — a half here, so the gap heads towards quartering every two steps: 1.14285714, then 0.29129464, then 0.07291085, then 0.01822908, then 0.00455729, then 0.00113932.

value iteration from zero, gamma = 1/2 step state 1 digits in gap at denominator state 1 v0 0 1 3.14285714 v2 2 1 1.14285714 v4 365/128 3 0.29129464 v6 25149/8192 4 0.07291085 v8 1638205/524288 6 0.01822908 v10 105303869/33554432 8 0.00455729 v12 6746787645/2147483648 10 0.00113932 the exact fixed point v1 = 22/7 = 3.142857... after twelve steps 3.14171782 the denominator grew by 9 digits and the answer was available at step zero

The denominator column is the part a decimal cannot show. Every iterate is a rational whose denominator carries one more power of two than the last, so the iteration is not slowly approaching 22/7 through numbers that are nearly it — it is walking through an infinite sequence of rationals none of which is 22/7, and getting more expensive to write down at every step. Ten digits after twelve steps, and nothing stops it.

Example · A discount closer to one

Keep the same chain and the same rewards and set the discount to nine tenths. The fixed point becomes 670/31 and 750/31, about 21.6 and 24.2, which is far larger — a patient decision-maker values the same stream much more highly. Row reduction still takes four operations.

Value iteration, on the other hand, is now multiplying the gap by 9/10 rather than 1/2 at each step, so after twelve steps it is nowhere near. The two methods have not changed. What has changed is that one of them is sensitive to a parameter the other is indifferent to, and that is the argument for solving rather than iterating.

Example · Three states, and the same four lines of work

A three-state chain with rewards 2, 0 and 5 and a discount of three quarters gives 1508/163, 1096/163 and 2192/163. The system is 3 by 3, row reduction handles it in one pass, and the residual is again exactly zero in every row.

The denominators of the iterates are worse here, not better: at twelve steps they run to eighteen digits. Nothing about the exact solve has got harder, and everything about the iteration has — which is the pattern rather than a feature of this instance.

Why value iteration exists at all

None of this makes the iteration useless, and the page is careful not to say so. It needs no matrix inverse and no elimination, it works when the state space is far too large to write I − γP down, and it extends directly to the case where an action has to be chosen in each state, where the map has a maximum in it and the system stops being linear. On a chain this small, with no action to choose, it is the slow way round — and seeing it be the slow way round on a small instance is how you learn what it is buying you on a large one.

What this course has not built

There is no decision here. Fix a policy and its value is a linear system; ask for the best policy and you need the maximum back inside the map, at which point the equation is no longer linear and the method that solves it alternates between evaluating a policy and improving it. That method needs a chain with a class structure and a steady state already in hand, which is Markov Chains, Decisions and Queues, and it is deliberately not attempted here.

And the discount itself is a modelling choice standing in for several different things — an interest rate, a probability of the process ending, an impatience — which happen to have the same arithmetic and quite different justifications. The value 22/7 is exactly right for γ = 1/2, and the question of whether 1/2 is the right number is not one the residual can answer.

Interactive

Value iteration, and the fixed point under it

One method approaches the answer and the other lands on it; both are exact here

Value iteration, and the fixed point under itthe iteration approaches the answer; row reduction lands on it
the first statethe secondthe exact fixed pointthe gap still left

Method

Solving for a value rather than iterating towards it

Four steps. The third is the one that makes the answer checkable, and it costs almost nothing.

1

Write the self-consistency condition, one equation per state

v(i) = r(i) + γ Σⱼ P(i,j) v(j). Resist the urge to read it as an assignment: it is a condition on the whole vector at once, and every state's equation mentions every other state's value.

2

Rearrange into (I − γP)v = r and check the discount is below one

Move the γPv across. If γ = 1 the matrix is singular for any stochastic P — the all-ones vector is in its kernel — and there is no unique solution to find. No such discount appears in the selector, and the solver behind it refuses a singular system by name rather than returning a number.

3

Solve by row reduction, in exact fractions

The same elimination used everywhere else on this path. For two or three states it is a handful of operations and the entries stay rational throughout, because the data are rational.

4

Substitute the answer back and confirm the residual is zero

Compute r + γPv − v row by row. In exact arithmetic it is 0, not nearly zero, and that is a check a floating-point solve cannot offer. It takes one pass and it converts a claim into something the reader can verify.

5

Only then compare with value iteration, and look at the denominators

Run the map from zero and watch two things: the gap shrinking towards a factor of γ a step, and the denominator growing by one power of γ's denominator each step. The second is the honest picture of what “never arrives” means.

Equations, fixed points and what iteration costs

Score 0 / 0

One system, solved and approached

The same two-state chain twice: once as a linear system with the answer checked by substitution, and once as a sequence of iterates with their denominators.

P = [ 1/2 1/2 ; 1/4 3/4 ] r = (1, 3) gamma = 1/2 SOLVED 3/4 v1 - 1/4 v2 = 1 -1/8 v1 + 5/8 v2 = 3 row reduction, four operations v1 = 22/7 = 3.142857 v2 = 38/7 = 5.428571 residual r + gamma P v - v = 0 , 0 exactly, both rows APPROACHED step state 1 state 2 denom digits v0 0 0 1 v2 2 17/4 1 v4 365/128 1315/256 3 v6 25149/8192 87747/16384 4 v8 1638205/524288 5673155/1048576 6 v10 105303869/33554432 363999427/67108864 8 v12 6746787645/2147483648 23310643395/4294967296 10 after twelve steps 3.14171782 gap 0.0011393229 the answer, available at step zero 3.142857... = 22/7 gap at state 1, every second step: 3.14285714 1.14285714 0.29129464 0.07291085 0.01822908 0.00455729 0.00113932 settling to a quarter of the last

The gap column is geometric in the limit, with ratio γ per step, which is a quarter per two steps at γ = 1/2; the early ratios sit a little above it because each step multiplies the gap by γP and P mixes the two states. Extrapolating it says the iteration needs about ten more steps per three decimal places and never terminates, and the denominator column says what those steps cost: one more digit each, forever.

For a rehearsal, set the discount to 99/100 in the selector and read the fixed point. Row reduction still does four operations and the residual is still exactly zero. Then look at the plot: after twenty-four steps, the most the slider allows, the iteration has barely left the axis. One method noticed the parameter and the other did not.

The harder rehearsal: set γ to 1/2 and change the rewards to (1, 1). Predict the fixed point before solving — every state pays 1 forever, discounted at a half, so the value should be 1/(1 − 1/2) = 2 in both states regardless of P. Check it, then perturb one entry of P and confirm that the value does not move at all. That invariance is a property of the equation, and it is a good test of whether the equation is understood rather than merely solved.

Common mistakes

1
Reading v = r + γPv as an assignmentIt is a condition satisfied by the whole vector at once, not a rule that computes v from an earlier v. Reading it as an assignment is exactly what turns it into value iteration, which is a legitimate method and is not what the equation says. The equation says v is a fixed point; the iteration is one way of hunting for one.
2
Treating the discount as purely a taste about the futureIt is also what makes I − γP invertible. At γ = 1 the all-ones vector is in the kernel of I − P for every stochastic P, so the system is singular and there is no unique value to find — the undiscounted infinite-horizon problem needs a different criterion altogether. The selector offers no such discount, and the solver refuses a singular system by name rather than returning something.
3
Concluding that value iteration is a mistakeIt is the slow way round here, on two states with no action to choose, and that is precisely why the comparison is worth making on a page. Where the matrix cannot be formed, or where a maximum sits inside the map and the system is no longer linear, the iteration is what there is. The lesson is about knowing which situation you are in, not about a winner.

Check your understanding

✓
Finish when you can turn v = r + γPv into a linear system, solve it in fractions, verify the residual is exactly zero, and explain what the iterates' denominators are telling you.

You should be able to say why an infinite horizon has no base case, rearrange the self-consistency condition into (I − γP)v = r, justify invertibility from γ < 1, solve a two-state or three-state system by row reduction, substitute back to get a zero residual, and describe value iteration as a sequence of exact rationals that approaches the answer without reaching it.

Note: That closes the course, and the last table was the one that could not be filled from the end. Looking back over the nine, the arithmetic was never the difficulty: every recursion here is three or four lines and every answer was checked against an exhaustive enumeration of the thing the recursion stands for. What varied was the state, and choosing it — units left rather than units spent, the period of the last order rather than the stock on hand, periods remaining rather than offers seen, a relative rank rather than a value. A recursion is exact about the state you gave it. Deciding what that state should be is the part no check on this page can do for you, and it is where this whole path says the error lives.

Kept in this browser only, for you. Nothing is sent anywhere and nothing checks it. Carry it to another device.

Feedback and recommendations

Something to change about this lesson? Write it down, tick it off when it is handled, and export the list when you want to act on it. Kept in this browser only: nothing is sent anywhere, and nobody is notified.

No recommendations yet for this lesson.