This Reinforcement Learning concept is the current idea: keep the same invariant visible across Intuition, Math, Code, Interactive Demo.
Reinforcement Learning
Function Approximation in RL
Function approximation replaces a Q-table with features and weights, so one TD update can generalize to nearby state-action pairs and can become unstable when bootstrapping, off-policy data, and approximation combine.
Concept Structure
Function Approximation in RL
Start with the picture, metaphor, or geometric mechanism.
Make the objects explicit and connect them with notation.
Mirror the equations with runnable implementation details.
Manipulate the mechanism and watch the idea respond.
Learner Contract
What this page should let you do.
2 prerequisites listed; refresh them before leaning on the math or code.
Explain the mechanism, trace the main notation, and test one prediction in the live demo.
Read the intuition before the notation; the math should name a mechanism you already felt.
Follow this edge after making one prediction here; the next page should reuse the result, not restart the route.
Claim/source review status
Substantive review recorded
1/1 claims have bounded review metadata; still check caveats and source scope.Metadata-derived; review may be AI-assisted. Not a human certification.01
Intuition
Build the mental picture first so the rest of the page has something to attach to.
Q-learning and SARSA used a table: one number for each state-action pair. That is clean, but it breaks the moment the state space becomes large, continuous, or visually rich.
Function approximation asks a different question:
Instead of storing every separately, what features of should share credit?
If the agent updates the value of Practice + Drill, a table changes only that cell. A feature-based approximator can also move Practice + Ask because both share the Practice-state feature, or Confused + Drill because both share the Drill-action feature. That is the power and the danger: one transition can generalize beyond itself.
The simplest version is linear. A feature map turns a state-action pair into a vector, and weights turn that vector into a value estimate. The update looks like TD learning, but it changes weights, not table cells.
The caution is not optional. Bootstrapping already uses an estimate as a target. Off-policy learning can train on data from a different policy than the one being improved. Function approximation spreads each update through shared features. Sutton and Barto call the combination of these three ingredients the deadly triad because it can cause oscillation or divergence. Deep Q-learning is powerful partly because it adds engineering devices around this problem, not because the problem vanished.
02
Math
Translate the story into symbols, assumptions, and a derivation you can inspect.
Let be a feature vector for state and action . A linear action-value approximator is
where is learned. More generally, can be a neural network, but the linear case makes the credit-sharing mechanism visible.
For a sampled transition
a SARSA-style target with approximation is
while a Q-learning-style target is
Both can be written as a semi-gradient update:
For the linear model, the gradient is just the active feature vector:
so the update becomes
This equation explains generalization. Another pair changes by
If the two feature vectors overlap, the unvisited pair moves. If they are orthogonal one-hot table features, it does not. The table is a special case of function approximation where every pair has its own isolated feature.
The word semi-gradient matters. When contains , the target itself depends on the current weights. The update treats the sampled target as fixed for the step rather than taking the full gradient through both sides of a Bellman error. That is useful and common, but it is exactly why convergence guarantees are narrower than the tabular story.
03
Code
Keep the implementation aligned with the notation so the algorithm is legible.
import numpy as np
alpha, gamma = 0.25, 0.90
w = np.array([0.45, 0.20, 0.25]) # state feature, action feature, pair detail
phi = {
("practice", "drill"): np.array([1.0, 1.0, 1.0]),
("practice", "ask"): np.array([1.0, 0.0, 0.0]),
("confused", "drill"): np.array([0.0, 1.0, 0.0]),
("confused", "ask"): np.array([0.0, 0.0, 1.0]),
}
transition = ("practice", "drill", 0.50, "confused")
next_actions = ["drill", "ask"]
s, a, reward, s_next = transition
q_current = w @ phi[(s, a)]
q_next = max(w @ phi[(s_next, a2)] for a2 in next_actions)
target = reward + gamma * q_next
td_error = target - q_current
w_new = w + alpha * td_error * phi[(s, a)]
for pair in phi:
before = w @ phi[pair]
after = w_new @ phi[pair]
print(pair, "before", round(before, 3), "after", round(after, 3))
The visited pair receives the biggest change because all three of its features are active. Pairs that share only the state or action feature move too. A one-hot table would not do that.
04
Interactive Demo
Use direct manipulation to connect the explanation to a moving system.
Use the RL Function Approximation Lab to predict what one TD update changes.
Choose a feature design, inspect the active feature vector and the TD target, then commit to whether the update should change only the visited pair, move feature-sharing neighbors too, or be treated as a caution case. After reveal, the lab shows the TD error, weight deltas, before/after estimates for nearby state-action pairs, and the reason the off-policy bootstrapped case needs extra care.
Live Concept Demo
Explore Function Approximation in RL
The stage is code-native and interactive. Use it to test the explanation against the mechanism.
Manipulate one control and predict the visible change.
Commit to what Function Approximation in RL should make visible before reading the result.
After The First Pass
Turn the concept into an inspected object.
Once the invariant is visible in the intuition, math, code, and demo, use these panels to inspect the mechanism visually, check source support, practice the idea, and attach a grounded research question.
Mechanism Storyboard
See the idea move before the page explains it
Function approximation replaces a Q-table with features and weights, so one TD update can generalize to nearby state-action pairs and can become unstable when bootstrapping, off-policy data, and approximation combine.
Start with the picture, metaphor, or geometric mechanism.
Before reading further, choose the kind of change Function Approximation in RL should make visible.
Visual Inquiry
Make the image answer a mathematical question
Function approximation replaces a Q-table with features and weights, so one TD update can generalize to nearby state-action pairs and can become unstable when bootstrapping, off-policy data, and approximation combine.
Which visible object should carry the first intuition?
Pick the cue that should make Function Approximation in RL easier to reason about before the page gives the answer.
Source Grounding
Canonical references for the mechanism on this page.
Canonical source for approximate value functions, feature vectors, semi-gradient prediction/control updates, action-value approximation, and the deadly-triad warning.
Open sourceGraduate RL source for TD and control with value-function approximation, SARSA/Q-learning approximation targets, and instability from bootstrapping, off-policy learning, and approximation.
Open sourceClaim Review
Function approximation replaces a Q-table with features and weights, so one TD update can generalize to nearby state-action pairs and can become unstable when bootstrapping, off-policy data, and approximation combine.
Claims without a substantive review badge still need exact source-support review.
sutton-barto-2018-rl, stanford-cs234-function-approximation-2026
Use equations, runnable code, and demos to check whether the source support is operational.
The sources support feature-based approximate value functions, semi-gradient updates that treat bootstrapped targets as targets for the current step, action-value control updates for SARSA and Q-learning, and the instability risk when function approximation, bootstrapping, and off-policy learning are combined.
Sources: Reinforcement Learning: An Introduction, Second Edition, Stanford CS234: Lecture 4, Model-Free Control and Function ApproximationLinear feature-based teaching lab only; excludes nonlinear neural-network optimization, replay buffers, target networks, Double DQN, distributional RL, eligibility traces, emphatic TD, gradient-TD methods, and formal convergence proofs.A bounded review summary is present; still check caveats and exact reference scope.Checked Sutton/Barto Chapters 9-11 for approximate values, feature vectors, semi-gradient methods, action-value approximation, off-policy divergence, and the deadly triad. Checked Stanford CS234 Lecture 4 pages 52-60 for TD/control with q_hat(s,a;w), approximate SARSA/Q-learning targets, and instability warnings. GPT Pro critique remains pending because 127.0.0.1:51672 is unavailable.
Reviewer: codex-local-source-review; reviewed 2026-07-03Source support candidates
book 2018Reinforcement Learning: An Introduction, Second EditionCanonical source for approximate value functions, feature vectors, semi-gradient prediction/control updates, action-value approximation, and the deadly-triad warning.
course-notes 2026Stanford CS234: Lecture 4, Model-Free Control and Function ApproximationGraduate RL source for TD and control with value-function approximation, SARSA/Q-learning approximation targets, and instability from bootstrapping, off-policy learning, and approximation.
Practice Loop
Try the idea before it explains itself
Function approximation replaces a Q-table with features and weights, so one TD update can generalize to nearby state-action pairs and can become unstable when bootstrapping, off-policy data, and approximation combine.
Before touching the demo, predict one visible change that should happen in Function Approximation in RL.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
Reveal when your model needs a nudge.
A concrete answer is on the canvas.
The answer names why the claim should hold.
It touches the page context or a neighboring idea.
Research Room
Attach the question to a claim, equation, code, or demo
Pick the concept, equation, source, runnable code, claim, misconception, or demo state before asking for help. The handoff keeps that page item in context.Open the draft below to save one note and next action in this browser.
Function Approximation in RL
What is the smallest example that makes Function Approximation in RL click without losing the math?
Local action draftNo local draft saved yetExpand only when ready to capture one local next action
This draft stays in this browser, attached to the selected learning item.
- References to inspect: attached references on this page.
- Definition, prerequisite, and contrast concept links
- The equation or runnable code that makes the concept operational
- One demo state that shows the invariant instead of a slogan
- The learner can state the mechanism in their own words
- The learner can name the prerequisite that would repair confusion
- The learner can predict how the mechanism changes under one perturbation
I am working in Continuous Function's research reading room. Object: concept - Function Approximation in RL Selected item key: recorded for copy. Context: Reinforcement Learning Page anchor: recorded for copy. Open question: What is the smallest example that makes Function Approximation in RL click without losing the math? Evidence to inspect: - References to inspect: attached references on this page. - Definition, prerequisite, and contrast concept links - The equation or runnable code that makes the concept operational - One demo state that shows the invariant instead of a slogan What would resolve this: - The learner can state the mechanism in their own words - The learner can name the prerequisite that would repair confusion - The learner can predict how the mechanism changes under one perturbation Answer as a careful research tutor: stay source-grounded, separate verified evidence from assumptions, name the relevant math objects, and end with one next action.
concept/concept-notebook/reinforcement-learning/rl-function-approximation
concept:reinforcement-learning/rl-function-approximation