Foundations — Temporal Difference learning
This page assumes you have seen nothing. Every letter in the parent note's equations is unpacked here, one at a time, each building on the last. Read top to bottom; do not skip.
0. The picture the whole topic lives inside

Everything in Temporal Difference learning is about an agent walking through states, collecting rewards. Look at the figure: a little dot (the agent) sits in a box (a state ), takes a step (an action ), lands in a new box, and a number pops out (a reward ). That is the entire world. Every symbol below labels one part of this picture.
1. State — where you are
Picture: one box in the grid of figure s01. Standing in that box is all you need to know to decide what to do next.
Why the topic needs it: value learning answers the question "how good is it to be here?" — and "here" is a state. Without naming the state, there is nothing to attach a value to.
- ::: the state at step (a variable — could be any box)
- ::: one specific state you point at
- terminal state ::: the last box of an episode; nothing happens after it, so its value is
2. Time-step — the ticking clock
Picture: the numbers written under each footprint as the dot walks in figure s01.
Why the topic needs it: TD's whole trick is comparing consecutive moments — versus . The clock is what lets us say "the next step."
3. Action and Reward
Picture: the arrow leaving a box (action) and the number floating above the arrow (reward) in figure s01.
Why the topic needs it: rewards are the only feedback the agent ever gets. Learning "how good a state is" means adding up rewards you expect to collect from it.
- ::: the action taken at step
- ::: the reward received after that action (a real number, can be negative)
4. Policy — the habit that picks actions
Picture: an arrow pre-drawn out of every box saying "if you're here, go this way."
Why the topic needs it: the value of a state only makes sense relative to a behaviour. "How good is this box?" depends on what you'll do afterward. fixes that behaviour. See SARSA and Q-Learning for what happens when we also improve .
5. Discount factor — future money is worth less

Picture: figure s02 shows a row of rewards at steps ; the bars shrink as . Near rewards are tall, far rewards are short.
Why this tool and not just "add everything"? If we added infinitely many rewards with equal weight, the sum could blow up to infinity and never settle. guarantees the total is a finite number, and it also encodes impatience — "a reward now beats the same reward later."
- All cases of :
- ::: agent is totally short-sighted, only the immediate reward matters
- ::: future rewards count but fade (the normal case)
- ::: no discounting — safe only when episodes are guaranteed to end
6. The Return — the whole prize from here on
Reading it in words: the reward you get next, plus times the one after, plus times the one after that, forever (or until the episode ends).
Picture: add up all the shrinking bars in figure s02 — that single grand total is .
Why the topic needs it: is the true quantity we wish we knew. But it lives in the future, so we can't see it until later. This is exactly the gap TD is built to bridge.
7. Expectation — the average over randomness
Picture: roll the same dice a thousand times, take the mean — that mean is . In figure s02, if the rewards were random, is the height each bar would settle to on average.
Why the topic needs it: the world is noisy. The same action can lead to different rewards or different next states. We don't want the value to jump around with luck — we want the average outcome. That is why value is defined as an expectation.
8. Value function — the number we're chasing
Picture: write a single number inside each box of figure s01 — "the average total prize you'll collect from here." That grid of numbers is the value function.
Why the topic needs it: this is the entire goal. Learning tells the agent which states are good and, indirectly, which moves are worth making.
- ::: the true value under policy
- ::: our current estimate of it — a guess we keep improving
9. Bellman equation — value defined by the next value
Why the second term became : the average of the return from the next state is, by definition, the value of the next state. That's the swap that turns an infinite sum into one clean reference to a neighbour. Full treatment in Bellman Equations.
Why the topic needs it: this says "a state's value is defined in terms of its neighbour's value." That self-referencing structure is what lets us learn by bootstrapping — improving one guess using another guess. Compare with Dynamic Programming, which uses this same equation but needs a full model, and Monte Carlo Methods, which ignores it and waits for full episodes.
10. The moving pieces of the TD update

Figure s03 lays the three quantities on a number line: the old guess , the TD target (a better-informed guess), and the small step (the gap between them) that pulls old toward target.
- ::: "gets replaced by" — an assignment, not an equals sign
- TD target ::: real reward you just saw + your current guess of the future
- TD error ::: how wrong the old guess was (an arrow in figure s03)
- — the learning rate (next section)
11. Learning rate — how big a nudge
Picture: in figure s03, is how far along the arrow we slide from old guess toward target.
- All cases of :
- ::: barely move — very slow, very stable learning
- ::: gentle nudges (typical)
- ::: throw away the old guess entirely, adopt the noisy target — unstable, jumps around
- or ::: forbidden — you'd overshoot or never learn
12. Prerequisite map
Read it bottom-up: states, actions, rewards, and discount feed the return; averaging the return under a policy gives the value function; the value function's self-referencing Bellman form enables bootstrapping, which — plus a learning rate — becomes the TD update.
Equipment checklist
Self-test: can you answer each before revealing?
- What does a state represent? ::: A complete description of the agent's current situation — the box the agent occupies at step .
- Why is the reward written and not ? ::: It is the reward received on arriving at the next state, so it carries the next step's subscript.
- What does the discount factor do and why is it needed? ::: It shrinks far-future rewards by , keeping the infinite sum finite and encoding impatience.
- Write the return and its one-step recursion. ::: .
- What does mean in plain words? ::: The average value, over all randomness while following policy , given you started in state .
- Define the value function . ::: The expected (average) return starting from state and following policy .
- State the Bellman equation for . ::: .
- What is the TD target and the TD error? ::: Target ; error .
- What does the learning rate control, and what goes wrong at ? ::: How far we move from old guess toward the target; discards the old estimate entirely, making learning unstable and noisy.
- Why can TD learn without a model? ::: It observes the next state and reward from real interaction rather than predicting them from transition dynamics.
Continue to: Temporal Difference learning · related: TD(λ), Value Function Approximation, 5.1.11 Temporal Difference learning (Hinglish)