Simple Algorithm
Reinforcement Learning · Fixed Point · 30 min

Convergence of TD: Stochastic Approximation

Robbins–Monro conditions, the ODE method and finite-time bounds.

Each TD(0) step changes a single entry of the table, using one noisy transition and a target made from the table itself. Why should that converge, and how fast? This lesson treats TD as stochastic approximation: an ordinary differential equation whose global stability follows from the contraction of the Bellman operator, step sizes that make or break convergence (with 1/n1/n steps, TD can need a number of updates exponential in the effective horizon), and the finite-time bounds of the late 2010s, including what changes when the samples come from one correlated trajectory.

What you’ll learn

  • Cast asynchronous TD(0) as stochastic approximation, identify its mean field, and state the Robbins–Monro conditions and the ODE method with its stability hypotheses.
  • Prove global exponential stability of the TD(0) ODE with a max-norm Lyapunov function, and derive the weighted-norm inequality that drives finite-time analyses.
  • Show that 1/n1/n step sizes can make TD exponentially slow in the effective horizon, and compare constant, rescaled-linear and averaged step sizes.
  • State finite-time bounds for TD with i.i.d. and Markovian samples, and the minimax and instance-dependent sample complexity of tabular TD, with their conditions.

TD(0) as stochastic approximation

Robbins and Monro (1951) asked how to find a root of a function that can only be measured with noise, and answered with an iteration of the form

θt+1=θt+αt(h(θt)+Mt+1),\theta_{t+1} = \theta_t + \alpha_t\big(h(\theta_t) + M_{t+1}\big),

where hh is the mean field and Mt+1M_{t+1} is noise with E[Mt+1∣Ft]=0\E[M_{t+1} \mid \mathcal F_t] = 0. TD(0) has exactly this shape. Write es\mathbf e_s for the unit vector of state ss. The update is Vt+1=Vt+αt δt eStV_{t+1} = V_t + \alpha_t\,\delta_t\,\mathbf e_{S_t}, and if the updated state is drawn from a distribution dd (and the transition from π\pi and PP), its conditional mean is

h(V)=E[δt eSt∣Vt=V]=D(rπ+γPπV−V)=D(TπV−V),D=diag⁡(d).h(V) = \E\big[\delta_t\,\mathbf e_{S_t} \mid V_t = V\big] = D\big(r^\pi + \gamma P^\pi V - V\big) = D\big(\mathcal T^\pi V - V\big),\qquad D = \diag(d).

The root of hh is the fixed point of Tπ\mathcal T^\pi: VπV^\pi. The noise Mt+1=δteSt−h(Vt)M_{t+1} = \delta_t\mathbf e_{S_t} - h(V_t) is a martingale difference whose conditional second moment grows at most quadratically, E[∥Mt+1∥2∣Ft]≤K(1+∥Vt∥2)\E[\norm{M_{t+1}}^2 \mid \mathcal F_t] \le K(1 + \norm{V_t}^2), for bounded rewards.

The intuition: on the time scale τt=∑k<tαk\tau_t = \sum_{k<t}\alpha_k, the iterates follow the ODE θ˙=h(θ)\dot\theta = h(\theta), because the accumulated noise ∑kαkMk+1\sum_k\alpha_kM_{k+1} is a martingale with summable variance, which converges. The first Robbins–Monro condition makes the ODE clock run forever; the second silences the noise. For TD(0), h(V)=D(TπV−V)h(V) = D(\mathcal T^\pi V - V) is affine and its scaled limit is h∞(V)=D(γPπ−I)Vh_\infty(V) = D(\gamma P^\pi - I)V, so both conditions reduce to the stability of one linear system.

Two details matter for tabular TD. If each state keeps its own step sequence over its visits, the natural conditions are ∑nαn(s)=∞\sum_n\alpha_n(s) = \infty and ∑nαn(s)2<∞\sum_n\alpha_n(s)^2 < \infty for every state. For max-norm contractions such as TD's, these per-state conditions suffice (Jaakkola, Jordan & Singh, 1994; Tsitsiklis, 1994), while the ODE version of the argument needs mild extra regularity on how often states are updated. And when the states come from a single trajectory instead of independent draws, the noise is Markovian; extensions of the ODE method cover it, with dd the chain's stationary distribution (Borkar, 2008).

Why the TD ODE is stable: two Lyapunov functions

DerivationProof with the max norm as a Lyapunov function
  1. W˙=D(γPπ−I) W\dot W = D\big(\gamma P^\pi - I\big)\,W

    Let W=V−VπW = V - V^\pi. Since TπVπ=Vπ\mathcal T^\pi V^\pi = V^\pi and Tπ\mathcal T^\pi is affine, the error obeys a linear ODE:

  2. ddt∣Wi∣=di sign⁡(Wi)(γ(PπW)i−Wi)≤di (γm−m)≤−dmin⁡(1−γ) m\frac{d}{dt}\abs{W_i} = d_i\,\sign(W_i)\big(\gamma(P^\pi W)_i - W_i\big) \le d_i\,(\gamma m - m) \le -d_{\min}(1-\gamma)\,m

    Let m(t)=∥W(t)∥∞m(t) = \norm{W(t)}_\infty, attained at some coordinate ii with ∣Wi∣=m\abs{W_i} = m. Because PπP^\pi is a stochastic matrix, ∣(PπW)i∣≤m\abs{(P^\pi W)_i} \le m, so the largest coordinate shrinks:

  3. m(t)≤e−dmin⁡(1−γ) t m(0)m(t) \le e^{-d_{\min}(1-\gamma)\,t}\,m(0)

    The upper derivative of a maximum is at most the largest derivative among the coordinates that attain it, so m˙≤−dmin⁡(1−γ)m\dot m \le -d_{\min}(1-\gamma)m, and Grönwall's inequality gives the exponential bound. ■\blacksquare

The proof used no property of dd beyond positivity. Tabular TD(0) is stable under any state-sampling distribution with full support, on-policy or not, as long as each transition follows π\pi. What breaks off-policy TD is function approximation, not the sampling distribution itself.

The second Lyapunov function is the one that generalizes to features. Take L(W)=12∥W∥22L(W) = \tfrac12\norm{W}_2^2 and suppose dd is the stationary distribution of PπP^\pi. Then ∥PπW∥D≤∥W∥D\norm{P^\pi W}_D \le \norm{W}_D by Jensen's inequality and stationarity, where ∥W∥D2=∑sd(s)W(s)2\norm{W}_D^2 = \sum_sd(s)W(s)^2, and Cauchy–Schwarz in the DD-inner product gives

⟨Vπ−V,  D(TπV−V)⟩=∥W∥D2−γ W⊤DPπW  ≥  (1−γ) ∥V−Vπ∥D2.\big\langle V^\pi - V,\; D(\mathcal T^\pi V - V)\big\rangle = \norm{W}_D^2 - \gamma\,W^\top DP^\pi W \;\ge\; (1-\gamma)\,\norm{V - V^\pi}_D^2.

The expected TD update always points at least partly toward VπV^\pi, by an amount measured in the stationary norm. TD is not the gradient of any objective, but this inequality lets its analysis mirror that of stochastic gradient descent on a strongly convex function. With features Φ\Phi it becomes the key lemma of the finite-time analysis below, (θ⋆−θ)⊤gˉ(θ)≥(1−γ)∥Vθ⋆−Vθ∥D2(\theta^\star - \theta)^\top\bar g(\theta) \ge (1-\gamma)\norm{V_{\theta^\star} - V_\theta}_D^2 (Bhandari, Russo & Singal, 2018), and it is also the heart of Tsitsiklis and Van Roy's (1997) convergence proof for linear TD.

Check your understanding

Tabular TD(0) evaluates π\pi, but the states to update are chosen from an arbitrary fixed distribution dd with d(s)>0d(s) > 0 everywhere (each chosen state's transition still follows π\pi). With Robbins–Monro steps, what happens?

  1. It can diverge, because dd is not the stationary distribution of π\pi: the deadly triad
  2. It converges to VπV^\pi, because the max-norm argument needs only d(s)>0d(s) > 0
  3. It converges, but to the values of the policy that generates dd
  4. It converges only if dd is uniform
Show the answer

B. It converges to VπV^\pi, because the max-norm argument needs only d(s)>0d(s) > 0

The max-norm Lyapunov proof uses only that every state is sampled with positive probability and that PπP^\pi is stochastic. The deadly triad needs function approximation as well; in a table, every state has its own parameter and the off-policy state distribution only changes the speed, through dmin⁡d_{\min}.

Step sizes: why 1/n can be a trap

The Robbins–Monro conditions say whether TD converges, not how fast. The step αn=1/n\alpha_n = 1/n is the natural choice, since it turns averaging into the exact sample mean, and for Monte Carlo it is optimal. For a bootstrapping method it can be disastrous. The smallest example shows why.

DerivationOne state, one loop, step size 1/k
  1. Wk+1=Wk+1k(r+γVk−Vk)=(1−1−γk)WkW_{k+1} = W_k + \frac1k\big(r + \gamma V_k - V_k\big) = \Big(1 - \frac{1-\gamma}{k}\Big)W_k

    A single state loops to itself with a deterministic reward rr, so Vπ=r/(1−γ)V^\pi = r/(1-\gamma) and there is no noise at all. TD(0) with αk=1/k\alpha_k = 1/k gives an error Wk=Vk−VπW_k = V_k - V^\pi that obeys

  2. Wk=W1∏j=1k−1(1−1−γj)=W1 Γ(k−1+γ)Γ(γ) Γ(k)  ∼  W1Γ(γ) k−(1−γ)W_k = W_1\prod_{j=1}^{k-1}\Big(1 - \frac{1-\gamma}{j}\Big) = W_1\,\frac{\Gamma(k-1+\gamma)}{\Gamma(\gamma)\,\Gamma(k)} \;\sim\; \frac{W_1}{\Gamma(\gamma)}\,k^{-(1-\gamma)}

    The product telescopes into Gamma functions, and Γ(k+a)/Γ(k)∼ka\Gamma(k + a)/\Gamma(k) \sim k^a:

  3. kε≈(ε Γ(γ))−1/(1−γ)k_\varepsilon \approx \big(\varepsilon\,\Gamma(\gamma)\big)^{-1/(1-\gamma)}

    The error decays only like k−(1−γ)k^{-(1-\gamma)}. Reaching a fraction ε\varepsilon of the initial error takes about ε−1/(1−γ)\varepsilon^{-1/(1-\gamma)} updates: polynomial in 1/ε1/\varepsilon, but with an exponent equal to the effective horizon, so exponential in it for a fixed accuracy. The cause is that each 1/k1/k step contracts the error by the factor 1−(1−γ)/k1 - (1-\gamma)/k instead of 1−1/k1 - 1/k: bootstrapping passes most of the old error into the new target.

Predict before you look

In the one-state loop with γ=0.9\gamma = 0.9 and αk=1/k\alpha_k = 1/k, what fraction of the initial error is still left after one million updates?

Show the answer

0.235

k−(1−γ)/Γ(γ)=(106)−0.1/Γ(0.9)≈0.251/1.069≈0.235k^{-(1-\gamma)}/\Gamma(\gamma) = (10^6)^{-0.1}/\Gamma(0.9) \approx 0.251/1.069 \approx 0.235; multiplying out the product exactly gives the same. Getting down to 1% would take about 5×10195 \times 10^{19} updates. At γ=0.99\gamma = 0.99, about 87% of the error is left after a million updates. A constant α=0.1\alpha = 0.1 would remove 99% of this noiseless error in about 460 updates.

Step sizeNoiseless error after kk stepsWith noise
αk=1/k\alpha_k = 1/k∼k−(1−γ)\sim k^{-(1-\gamma)}: exponentially slow in the horizonconverges, but slowly
constant α\alpha(1−α(1−γ))k(1 - \alpha(1-\gamma))^k: fastdoes not converge; hovers with mean squared error of order α\alpha
rescaled linear, αk=11+(1−γ)k\alpha_k = \frac{1}{1 + (1-\gamma)k}exactly W1/(1+(1−γ)(k−1))W_1/(1 + (1-\gamma)(k-1)): order 1(1−γ)k\frac{1}{(1-\gamma)k}converges at the usual 1/k1/k statistical rate
polynomial, αk=k−ω\alpha_k = k^{-\omega} with 12<ω<1\tfrac12 < \omega < 1exp⁡(−c (1−γ)k1−ω)\exp(-c\,(1-\gamma)k^{1-\omega})converges; error of order k−ωk^{-\omega}
constant or polynomial steps with iterate averagingfast, as for the steps usedasymptotically optimal covariance (Polyak & Juditsky, 1992)
Even-Dar and Mansour (2003) showed the same dichotomy for Q-learning: linear 1/n1/n steps can need time exponential in 1/(1−γ)1/(1-\gamma), polynomial steps polynomial time. Rescaled linear steps are the choice of several sharp analyses of tabular TD and Q-learning.

Finite-time bounds and sample complexity

Asymptotic convergence says nothing about a finite budget. The late 2010s produced explicit bounds, stated for linear TD(0), Vθ=ΦθV_\theta = \Phi\theta, which includes the tabular case with Φ=I\Phi = I.

The analysis is the stochastic-gradient template with the inequality of the previous step in the role of strong convexity: the expected update points toward θ⋆\theta^\star with strength (1−γ)ω(1-\gamma)\omega, and the noise adds a term proportional to the step. Srikant and Ying (2019) removed the projection for constant steps with Markovian noise, using a Lyapunov function found by Stein's method: the mean squared error decays geometrically to a steady-state level of order α τmix\alpha\,\tau_{\mathrm{mix}}. They also showed that the steady-state error need not have light tails: in their example, moments of high enough order (growing faster than 1/α1/\alpha) are infinite.

How many samples does tabular TD need? With a generative model that samples every state in each round, and accuracy measured in the max norm, synchronous TD needs on the order of ∣S∣/((1−γ)3ε2)\abs{\mathcal S}/\big((1-\gamma)^3\varepsilon^2\big) samples up to logarithmic factors, which matches the minimax lower bound for policy evaluation; Q-learning, by contrast, needs order ∣S∣∣A∣/((1−γ)4ε2)\abs{\mathcal S}\abs{\mathcal A}/\big((1-\gamma)^4\varepsilon^2\big), one horizon factor more, and this is tight for it (Li, Cai, Chen, Wei & Chi, 2024). Minimax optimality is a worst-case statement. On a particular problem, Khamaru, Pananjady, Ruan, Wainwright and Jordan (2021) show that TD with Polyak–Ruppert averaging can be strictly worse than the instance-dependent optimum, while a variance-reduced variant attains it up to logarithmic factors.

Key takeaways

  • Tabular TD(0) is stochastic approximation with mean field h(V)=D(TπV−V)h(V) = D(\mathcal T^\pi V - V) and martingale-difference noise; the ODE method of Borkar and Meyn turns stability of V˙=h(V)\dot V = h(V) and of its scaled limit into almost-sure convergence.
  • The max norm is a Lyapunov function: ∥V(t)−Vπ∥∞\norm{V(t) - V^\pi}_\infty decays at rate dmin⁡(1−γ)d_{\min}(1-\gamma) for any sampling distribution with full support; under the stationary distribution, the expected update satisfies ⟨Vπ−V,h(V)⟩≥(1−γ)∥V−Vπ∥D2\langle V^\pi - V, h(V)\rangle \ge (1-\gamma)\norm{V - V^\pi}_D^2.
  • With αk=1/k\alpha_k = 1/k the error of a bootstrapping method can decay like k−(1−γ)k^{-(1-\gamma)}, exponentially slow in the effective horizon; constant, rescaled-linear, polynomial and averaged steps avoid this.
  • Finite-time bounds give O(1/T)O(1/T) rates with constants in (1−γ)−2ω−2(1-\gamma)^{-2}\omega^{-2}, a noise ball of order α\alpha (times the mixing time for Markovian data) for constant steps, and a minimax-optimal ∣S∣/((1−γ)3ε2)\abs{\mathcal S}/((1-\gamma)^3\varepsilon^2) sample complexity for synchronous TD.

Check yourself

In the interactive lesson these are scored with your confidence, and what you miss comes back for review.

Question 1

States to update are drawn from a distribution dd and transitions follow π\pi. What is the mean field h(V)h(V) of tabular TD(0)?

  1. TπV−V\mathcal T^\pi V - V
  2. D(TπV−V)D(\mathcal T^\pi V - V) with D=diag⁡(d)D = \diag(d)
  3. D(Vπ−V)D(V^\pi - V)
  4. ∇V 12∥TπV−V∥D2\nabla_V\,\tfrac12\norm{\mathcal T^\pi V - V}_D^2
Show the answer

B. D(TπV−V)D(\mathcal T^\pi V - V) with D=diag⁡(d)D = \diag(d)

Only the sampled state moves, by αδt\alpha\delta_t, and E[δt∣St=s]=(TπV)(s)−V(s)\E[\delta_t \mid S_t = s] = (\mathcal T^\pi V)(s) - V(s). Weighting by how often each state is sampled gives D(TπV−V)D(\mathcal T^\pi V - V), whose root is VπV^\pi.

Question 2

You want tabular TD(0) to converge with probability 1 (both Robbins–Monro conditions) and to escape the k−(1−γ)k^{-(1-\gamma)} slowdown that 1/k1/k steps cause at long horizons. Which schedule for the kk-th update of a state does both?

  1. αk=1/k\alpha_k = 1/k, the exact running mean
  2. αk=1/k0.7\alpha_k = 1/k^{0.7}
  3. αk=0.05\alpha_k = 0.05
  4. αk=1/k2\alpha_k = 1/k^2
Show the answer

B. αk=1/k0.7\alpha_k = 1/k^{0.7}

∑kk−0.7=∞\sum_k k^{-0.7} = \infty and ∑kk−1.4<∞\sum_k k^{-1.4} < \infty, so both conditions hold, and in the noiseless loop the error shrinks like exp⁡(−(1−γ)k0.3/0.3)\exp\big(-(1-\gamma)k^{0.3}/0.3\big): for a fixed accuracy the number of updates is polynomial, not exponential, in the effective horizon. The rescaled linear step 1/(1+(1−γ)k)1/(1 + (1-\gamma)k) from the lesson's step-size table also does both.

Question 3

Why can TD(0) with αk=1/k\alpha_k = 1/k be extremely slow when γ\gamma is close to 1, even without any noise?

  1. Because 1/k1/k violates the Robbins–Monro conditions
  2. Because each step shrinks the error only by the factor 1−(1−γ)/k1 - (1-\gamma)/k, so it decays like k−(1−γ)k^{-(1-\gamma)}
  3. Because the TD error is biased, so TD converges to the wrong value
  4. Because the variance of the updates grows with kk
Show the answer

B. Because each step shrinks the error only by the factor 1−(1−γ)/k1 - (1-\gamma)/k, so it decays like k−(1−γ)k^{-(1-\gamma)}

Bootstrapping feeds most of the current error back into the target, so the effective contraction per step is (1−γ)/k(1-\gamma)/k instead of 1/k1/k. The product decays like k−(1−γ)k^{-(1-\gamma)}: about 77% of the error is gone after a million steps at γ=0.9\gamma = 0.9, but only 13% at γ=0.99\gamma = 0.99.

Question 4

With a generative model and max-norm accuracy ε\varepsilon, which statement about sample complexity is correct (up to logarithmic factors)?

  1. TD and Q-learning both need order ∣S∣∣A∣/((1−γ)3ε2)\abs{\mathcal S}\abs{\mathcal A}/\big((1-\gamma)^3\varepsilon^2\big) samples
  2. TD needs order ∣S∣/((1−γ)4ε2)\abs{\mathcal S}/\big((1-\gamma)^4\varepsilon^2\big), one horizon factor above the lower bound
  3. No finite-sample bound is known for tabular TD
  4. Synchronous TD needs order ∣S∣/((1−γ)3ε2)\abs{\mathcal S}/\big((1-\gamma)^3\varepsilon^2\big), matching the minimax lower bound, while Q-learning needs order ∣S∣∣A∣/((1−γ)4ε2)\abs{\mathcal S}\abs{\mathcal A}/\big((1-\gamma)^4\varepsilon^2\big)
Show the answer

D. Synchronous TD needs order ∣S∣/((1−γ)3ε2)\abs{\mathcal S}/\big((1-\gamma)^3\varepsilon^2\big), matching the minimax lower bound, while Q-learning needs order ∣S∣∣A∣/((1−γ)4ε2)\abs{\mathcal S}\abs{\mathcal A}/\big((1-\gamma)^4\varepsilon^2\big)

Li, Cai, Chen, Wei and Chi (2024) settled both: TD (the one-action case) is minimax optimal, and Q-learning's extra horizon factor is real, a consequence of the overestimation that the max introduces. Variance-reduced and model-based methods attain the (1−γ)−3(1-\gamma)^{-3} rate for control.

Further reading

  • V. S. Borkar & S. P. Meyn, "The O.D.E. method for convergence of stochastic approximation and reinforcement learning," SIAM Journal on Control and Optimization 38(2), 447–469 (2000).
  • J. N. Tsitsiklis, "Asynchronous stochastic approximation and Q-learning," Machine Learning 16, 185–202 (1994).
  • J. Bhandari, D. Russo & R. Singal, "A finite time analysis of temporal difference learning with linear function approximation," Conference on Learning Theory (COLT) (2018); Operations Research 69(3), 950–973 (2021).
  • R. Srikant & L. Ying, "Finite-time error bounds for linear stochastic approximation and TD learning," Conference on Learning Theory (COLT) (2019).
  • G. Li, C. Cai, Y. Chen, Y. Wei & Y. Chi, "Is Q-learning minimax optimal? A tight sample complexity analysis," Operations Research 72(1), 222–236 (2024).