Exercises — Policies and value functions
This is a self-testing page for Policies and value functions. Work each problem before opening the collapsible solution. Problems climb from L1 Recognition (can you spot the object?) up to L5 Mastery (can you build the argument?).
Before we start, three reminders we will use constantly — every symbol here was built in the parent note:
Recall The three objects we keep reaching for
- Policy ::: a rule that turns a state into an action (or a probability over actions), written .
- State value ::: expected discounted total reward if you start in and act by forever.
- Action value ::: same idea, but you force the first action to be , then follow .
We will also need the time-index and expectation notation one more time, because Exercise 5.1 uses it directly:
Two number facts we will reuse:
The picture below is the visual proof of that shortcut — you will call on it in Exercises 2.1, 2.2 and 5.1. The teal bars are the individual discounted rewards ; the plum curve is the running total climbing toward the orange ceiling .

Notice the running total flattens as it approaches the ceiling: adding more steps barely changes the sum once the terms have shrunk enough. That flattening is exactly why an infinite reward stream has a finite value — keep this bar picture in mind when you solve the self-loop problems.
Level 1 — Recognition
Exercise 1.1 (L1). Classify each as a policy, a state-value function, or an action-value function: (a) (b) (c) (d) "always move toward the goal".
Recall Solution 1.1
(a) policy — it assigns a probability to an action given a state. (b) action-value — it scores a (state, action) pair. (c) state-value — it scores a state alone. (d) policy — a deterministic rule from state to action.
Exercise 1.2 (L1). In the identity , what kind of average is the right-hand side?
Recall Solution 1.2
It is a weighted average of the -values, where the weights are the policy probabilities . Since , the weights are a valid probability distribution — so can never exceed the best or fall below the worst in that state.
Level 2 — Application
Exercise 2.1 (L2). An agent in state receives reward on every step forever, with . Find .
Recall Solution 2.1
WHAT: every step gives the same . WHY the geometric shortcut: identical rewards discounted by a constant factor form a geometric series — exactly the teal bars in the figure above, but with .
Exercise 2.2 (L2). A self-loop state gives reward each step and never leaves, . Write its Bellman equation and solve.
Recall Solution 2.2
Bellman equation (only one next state, itself): WHY: immediate reward , then discounted value of landing back in . Solve: (Matches the geometric shortcut — the orange ceiling from the figure with .)
Exercise 2.3 (L2). From state , taking action gives immediate reward and lands deterministically in with , . Compute .
Recall Solution 2.3
Only one next state, so the sum collapses to one term:
Level 3 — Analysis
Exercise 3.1 (L3). Two-state chain. From under policy : reward , then go to w.p. and w.p. . From : self-loop reward . . Find .
The diagram below is exactly this chain — read the arrows off it as you set up the equation.

Recall Solution 3.1
From 2.2 we already have . Bellman equation for : WHY term by term:
- The leading is the immediate reward collected on this step from — undiscounted, because you get it now.
- The factor multiplies the whole future, because everything after this step is one step away.
- Inside the bracket is the expectation over next states: with probability you land back in (contributing ) and with probability you reach (contributing ). We average because the next state is random.
Plug : Interpretation: because you might loop back into the lower-reward state before escaping.
Exercise 3.2 (L3). Same as above but two actions: (reward , go to ), (reward , stay in ). Policy , , . Find . (The two-action version of is drawn in the figure above — the plum arrow is , the teal self-loop is .)
Recall Solution 3.2
First, a fixed number, then a coupled system of two equations. The action value of is not self-referential — it lands in whose value we already know — so we compute it once as a constant: The genuine coupling is between the two unknowns and , giving a linear system of two equations in two unknowns: Substitute (i) into (ii): Since , action is better — consistent with favouring it (80%).
Level 4 — Synthesis
Exercise 4.1 (L4). In state there are three actions with . (a) Under the current policy , find . (b) A greedy improvement makes the policy always pick the best action. What is the new value of for this one step's action choice, i.e. ? (c) How much did the value improve?
Recall Solution 4.1
(a) Weighted average: (b) Greedy picks the max : (action ). (c) Improvement . WHY it improved: moving probability off the worse actions () onto the best action () can only raise the average — this is the seed idea of the policy improvement theorem.
Exercise 4.2 (L4). Given and , write the Bellman optimality equation for by substitution, then read off the optimal policy .
Recall Solution 4.2
Substitute into : The optimal policy is greedy with respect to . To keep the policy-as-distribution formalism used everywhere else on this page, we write it as a distribution that puts all its mass on the maximizing action(s): (If several actions tie for the max, any split of the probability among them is also optimal.) WHY: if you always take a highest- action, you are, by definition, achieving the max in the equation above at every state — that is what "optimal" means. This is the fixed point that value iteration and Q-learning chase.
Level 5 — Mastery
Exercise 5.1 (L5). Prove the geometric bound: if all rewards satisfy and , then for every policy and state, . Then evaluate the upper bound for . (Recall from the top of the page: is the reward steps after now, and averages over all random futures under .)
Recall Solution 5.1
Lower bound: every reward and every weight (, plus the probabilities inside the average) is , so the expected sum is . Upper bound: replace each future reward by its ceiling : WHY the swap is legal: replacing each random reward by a value at least as large can only increase the sum, and the expectation preserves inequalities (averaging bigger numbers gives a bigger average). Once every reward is the constant , there is nothing random left, so drops away and we get the geometric series from the figure — finite precisely because . Number: . (Consistent with the self-loop capping exactly at when reward is always .)
Exercise 5.2 (L5). Consider a state with two actions. Let . Show that among all policies over these two actions, the value is maximized at , and find that maximum. Interpret via .
Recall Solution 5.2
Write , for . The coefficient , so is increasing in ; its maximum on is at : Interpretation: the value-maximizing (optimal) policy puts all its probability on the higher- action — i.e. , matching the greedy distribution from Exercise 4.2. This is exactly why deterministic greedy policies are enough to be optimal in a finite MDP.
Back to the parent: Policies and value functions · foundations in Introduction to RL and MDPs.