Derive the Bellman expectation equation for Vπ. How does the Bellman optimality equation for V∗ differ, and why can the first be solved as a linear system but not the second?

Reinforcement learning, Bellman equations
Level L3 Intermediate. Length Medium. Nature Mat Mathematical.

What's being asked

Whether you can derive the recursive form of the value function from the definition of the return, and explain where the max comes in.

Key idea

Because Gt=rt+1+γGt+1, Vπ(s)=∑aπ(a∣s)∑s′P(s′∣s,a)[R(s,a,s′)+γVπ(s′)]. The optimality equation replaces the average over π with a max over actions: V∗(s)=max⁡a∑s′P(s′∣s,a)[R(s,a,s′)+γV∗(s′)].

Steps

  1. Start from Vπ(s)=Eπ[Gt∣st=s] and the recursion Gt=rt+1+γGt+1.
  2. Condition on the first action and the next state: Vπ(s)=∑aπ(a∣s)∑s′P(s′∣s,a)(R(s,a,s′)+γ Eπ[Gt+1∣st+1=s′]). By the Markov property the inner expectation is Vπ(s′).
  3. Stack the values of all states into a vector. Let Rπ be the vector of expected one-step rewards under π, and Pπ the matrix with Pss′π=∑aπ(a∣s)P(s′∣s,a). Then Vπ=Rπ+γPπVπ, so Vπ=(I−γPπ)−1Rπ. The inverse exists because Pπ is a stochastic matrix and γ<1, so all eigenvalues of γPπ have modulus below 1.
  4. Write the optimality equation, and the action-value versions: Qπ(s,a)=∑s′P(s′∣s,a)[R(s,a,s′)+γ∑a′π(a′∣s′)Qπ(s′,a′)] and Q∗(s,a)=∑s′P(s′∣s,a)[R(s,a,s′)+γmax⁡a′Q∗(s′,a′)].
  5. Explain that the max makes the optimality equation non-linear, so it is solved iteratively (value iteration, policy iteration) or from samples (Q-learning), not by one matrix inversion.

Common mistakes

How long your answer should be

Half a page: the derivation in 3–4 lines, then the two equations side by side.

Last checked on 4 December 2026.

Read this

Previous in Reinforcement learning: How do you derive the REINFORCE policy-gradient estimator, and why does subtracting a baseline not introduce bias?
Next in Reinforcement learning: Compare Monte Carlo and TD(0) value estimation in terms of bias and variance. Given eight episodes, one (A, 0, B, 0), six (B, 1) and one (B, 0), with γ=1, what do batch Monte Carlo and batch TD(0) give for V(A) and V(B)?