Definition · The discounted value of a policyFix 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 oneKeep 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 workA 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.