Regularized and ordinary Bellman equations are both functional equations: the unknown is a function rather than a finite vector. How can such an equation be approximated by finitely many coefficients while retaining a precise condition on its residual?
The Bellman optimality equation , whose contraction property underlies the convergence of value iteration, is a functional equation: an equation where the unknown is an entire function rather than a finite-dimensional vector. When the state space is continuous or very large, we cannot represent the value function exactly on a computer. We must instead work with finite-dimensional approximations. This motivates weighted residual methods (also called minimum residual methods), a general framework for transforming infinite-dimensional problems into tractable finite-dimensional ones Chakraverty et al. (2019)Atkinson & Potra (1987).
A Motivating Example: Optimal Stopping with Continuous States¶
What fails when an exact value function lives on a continuum but only finitely many coefficients can be stored?
Before developing the general theory, consider a concrete example that illustrates the core challenge. An agent observes a state and must decide whether to stop (receive reward and end the episode) or continue (receive nothing, and the state redraws uniformly on ). With discount factor , the Bellman optimality equation is:
The first term is the immediate payoff from stopping; the second is the discounted expected continuation value. Since the continuation value is a constant (it doesn’t depend on the current state ), the optimal policy has a threshold structure: stop if for some threshold , continue otherwise.
At the threshold, the agent is indifferent: . Computing by integrating :
Substituting and solving gives the exact threshold and value.
Source
# label: fig-optimal-stopping-exact
# caption: The exact value function for the optimal stopping problem.
%config InlineBackend.figure_format = 'retina'
import numpy as np
import matplotlib.pyplot as plt
gamma = 0.9
# Solve for exact threshold
v_bar_exact = (1 - np.sqrt(1 - gamma**2)) / gamma**2
s_star_exact = gamma * v_bar_exact
print(f"Exact solution:")
print(f" Threshold s* = {s_star_exact:.6f}")
print(f" Continuation value v̄ = {v_bar_exact:.6f}")
# The exact value function
def v_exact(s):
return np.where(s >= s_star_exact, s, gamma * v_bar_exact)
# Plot the exact value function
s_grid = np.linspace(0, 1, 200)
plt.figure(figsize=(8, 4))
plt.plot(s_grid, v_exact(s_grid), 'b-', linewidth=2, label='Exact $v^*(s)$')
plt.axvline(s_star_exact, color='r', linestyle='--', label=f'Threshold $s^* = {s_star_exact:.3f}$')
plt.xlabel('State $s$')
plt.ylabel('Value $v^*(s)$')
plt.legend()
plt.title('Optimal Stopping: Exact Value Function')
plt.grid(True, alpha=0.3)
plt.tight_layout()Exact solution:
Threshold s* = 0.626789
Continuation value v̄ = 0.696432

The exact value function is piecewise linear: constant at below the threshold, equal to above it. Now suppose we want to approximate using a polynomial basis with terms:
The residual at state measures how far our approximation is from satisfying the Bellman equation:
For a perfect solution, for all . But a polynomial cannot exactly represent the kink at . We must choose how to make the residual “small” across the state space.
Collocation picks points and requires the residual to vanish exactly there:
Galerkin requires the residual to be orthogonal to each basis function:
Source
# label: fig-collocation-comparison
# caption: Polynomial collocation approximation with 5 Chebyshev nodes.
from scipy.integrate import quad
def chebyshev_nodes(n, a=0, b=1):
"""Chebyshev nodes on [a, b]."""
k = np.arange(1, n + 1)
nodes = 0.5 * (a + b) + 0.5 * (b - a) * np.cos((2*k - 1) * np.pi / (2*n))
return np.sort(nodes)
def collocation_solve(n, gamma, max_iter=100, tol=1e-8):
"""Solve optimal stopping via polynomial collocation."""
nodes = chebyshev_nodes(n)
Phi = np.vander(nodes, n, increasing=True)
theta = np.zeros(n)
for iteration in range(max_iter):
def v_approx(s):
return sum(theta[j] * s**j for j in range(n))
v_bar, _ = quad(v_approx, 0, 1)
targets = np.maximum(nodes, gamma * v_bar)
theta_new = np.linalg.solve(Phi, targets)
if np.linalg.norm(theta_new - theta) < tol:
return theta_new, iteration + 1
theta = theta_new
return theta, max_iter
# Solve with different numbers of basis functions
for n in [3, 5, 8]:
theta, iters = collocation_solve(n, gamma)
def v_approx(s, theta=theta, n=n):
return sum(theta[j] * s**j for j in range(n))
errors = [abs(v_approx(s) - v_exact(s)) for s in np.linspace(0, 1, 1000)]
print(f"n = {n}: converged in {iters} iters, max error = {max(errors):.6f}")
# Plot comparison for n=5
n = 5
theta, _ = collocation_solve(n, gamma)
v_approx_5 = lambda s: sum(theta[j] * s**j for j in range(n))
plt.figure(figsize=(8, 4))
plt.plot(s_grid, v_exact(s_grid), 'b-', linewidth=2, label='Exact')
plt.plot(s_grid, [v_approx_5(s) for s in s_grid], 'r--', linewidth=2, label=f'Collocation ($n={n}$)')
plt.scatter(chebyshev_nodes(n), [v_approx_5(s) for s in chebyshev_nodes(n)],
color='red', s=50, zorder=5, label='Collocation nodes')
plt.xlabel('State $s$')
plt.ylabel('Value')
plt.legend()
plt.title('Polynomial Collocation Approximation')
plt.grid(True, alpha=0.3)
plt.tight_layout()n = 3: converged in 49 iters, max error = 0.053991
n = 5: converged in 41 iters, max error = 0.052626
n = 8: converged in 54 iters, max error = 0.015880

This example illustrates the fundamental tension in weighted residual methods: with finite parameters, we cannot satisfy the Bellman equation everywhere. We must choose how to allocate our approximation capacity. The rest of this chapter develops the general theory behind these choices.
Testing Whether a Residual Vanishes¶
Which scalar conditions can certify that a functional residual is zero, small, or orthogonal to selected directions?
Consider a functional equation , where is an operator and the unknown is an entire function (in our case, the Bellman optimality equation , which we can write as ). Suppose we have found a candidate approximate solution . To verify it satisfies , we compute the residual function . For a true solution, this residual should be the zero function: for every state .
How might we test whether a function is zero? One approach: sample many input points , check whether at each, and summarize the results into a single scalar test by computing a weighted sum with weights . If is zero everywhere, this sum is zero. If is nonzero somewhere, we can choose points and weights to make the sum nonzero. For vectors in finite dimensions, the inner product implements exactly this idea: it tests by weighting and summing. Indeed, a vector equals zero if and only if for every vector . To see why, suppose . Choosing gives , contradicting the claim that all inner products vanish.
The same principle extends to functions. A function equals the zero function if and only if its “inner product” with every “test function” vanishes:
where is a weight function that is part of the inner product definition. Why does this work? For the same reason as in finite dimensions: if is not the zero function, there must be some region where . We can then choose a test function that is nonzero in that same region (for instance, itself), which will produce , witnessing that is nonzero. Conversely, if is the zero function, then for any test function .
This ability to distinguish between different functions using inner products is a fundamental principle from functional analysis. Just as we can test a vector by taking inner products with other vectors, we can test a function by taking inner products with other functions.
Connection to Functional Analysis
The principle that “a function equals zero if and only if it has zero inner product with all test functions” is a consequence of the Hahn-Banach theorem, one of the cornerstones of functional analysis. The theorem guarantees that for any nonzero function in a suitable function space, there exists a continuous linear functional (which can be represented as an inner product with some test function ) that produces a nonzero value when applied to . This is often phrased as “the dual space separates points.”
While you don’t need to know the Hahn-Banach theorem to use weighted residual methods, it provides the rigorous mathematical foundation ensuring that our inner product tests are theoretically sound. The constructive argument we gave above (choosing ) works in simple cases with well-behaved functions, but the Hahn-Banach theorem extends this guarantee to much more general settings.
This transforms the pointwise condition “ for all ” (infinitely many conditions, one per state) into an equivalent condition about inner products. We still cannot test against all possible test functions, since there are infinitely many of those too. But the inner product perspective suggests a natural computational strategy: choose a finite collection of test functions and use them to construct conditions that we can actually compute.
From Variational Conditions to Optimization¶
Making a residual “small” is an optimization problem. We want to find that minimizes for some norm. Different methods correspond to different choices of norm:
Minimize the weighted norm
Minimize a discrete norm at selected points
Minimize in a dual norm induced by the approximation space
The first-order conditions for these optimization problems take the form for appropriate “test functions” . The variational formulation is useful for analysis, but we are simply minimizing the residual in a chosen norm.
The rest of this chapter develops the computational framework: how to parameterize the unknown function, define the residual, choose a norm, and solve the resulting finite-dimensional problem.
The General Framework¶
How do an approximation space, residual, test space, and solver combine into a reusable finite-dimensional method?
Consider an operator equation of the form
where is a continuous operator between complete normed vector spaces and . For the Bellman equation, we have , so that solving is equivalent to finding the fixed point .
Just as we transcribed infinite-dimensional continuous optimal control problems into finite-dimensional discrete optimal control problems in earlier chapters, we seek a finite-dimensional approximation to this infinite-dimensional functional equation. Recall that for continuous optimal control, we adopted control parameterization: we represented the control trajectory using a finite set of basis functions (piecewise constants, polynomials, splines) and searched over the finite-dimensional coefficient space instead of the infinite-dimensional function space. For integrals in the objective and constraints, we used numerical quadrature to approximate them with finite sums.
We follow the same strategy here. We parameterize the value function using a finite set of basis functions , commonly polynomials (Chebyshev, Legendre), though other function classes (splines, radial basis functions, neural networks) are possible, and search for coefficients in . When integrals appear in the Bellman operator or projection conditions, we approximate them using numerical quadrature. The projection method approach consists of several conceptual steps that accomplish this transcription.
Step 1: Choose a Finite-Dimensional Approximation Space¶
We begin by selecting a basis and approximating the unknown function as a linear combination:
The choice of basis functions is problem-dependent. Common choices include:
Polynomials: For smooth problems, we might use Chebyshev polynomials or other orthogonal polynomial families
Splines: For problems where we expect the solution to have regions of different smoothness
Radial basis functions: For high-dimensional problems where tensor product methods become intractable
The number of basis functions determines the flexibility of our approximation. In practice, we start with small and increase it until the approximation quality is satisfactory. The only unknowns now are the coefficients .
While the classical presentation of projection methods focuses on polynomial bases, the framework applies equally well to other function classes. Neural networks, for instance, can be viewed through this lens: a neural network with parameters defines a flexible function class, and many training procedures can be interpreted as projection methods with specific choices of test functions or residual norms. The distinction is that classical methods typically use predetermined basis functions with linear coefficients, while neural networks use adaptive nonlinear features. Throughout this chapter, we focus on the classical setting to develop the core concepts, but the principles extend naturally to modern function approximators.
Step 2: Define the Residual Function¶
Since we are approximating with , the operator will generally not vanish exactly. Instead, we obtain a residual function:
This residual measures how far our candidate solution is from satisfying the equation at each point . As we discussed in the introduction, we want to make this residual small—an optimization problem whose formulation depends on how we measure “small.”
Step 3: Impose Conditions on the Residual¶
The basis and residual reduce the functional equation to scalar conditions on . The choice of conditions determines the method:
| Method | Residual criterion | Conditions ( equations) |
|---|---|---|
| Least squares | , | |
| Galerkin | (dual norm of approx. space) | , |
| Collocation | Exact pointwise satisfaction | , |
Each criterion yields equations in the unknowns .
Collocation: Make the Residual Zero at Selected Points¶
The simplest approach is to choose points and require the residual to vanish exactly at each:
This gives equations for unknowns. Collocation is computationally attractive because it avoids integration entirely—we only evaluate at discrete points. The resulting system is:
For a linear operator, this is a linear system; for the Bellman equation, it is nonlinear due to the max.
Verify for yourself: with collocation points and basis functions, the system is a linear system. What must be true about the collocation matrix for this system to have a unique solution?
The choice of collocation points matters. Orthogonal collocation (or spectral collocation) places points at the zeros of the -th orthogonal polynomial in a family (Chebyshev, Legendre, etc.). For Chebyshev polynomials , we place collocation points at the zeros of . These points are also optimal nodes for Gauss quadrature, so:
We get the computational simplicity of pointwise evaluation
When we need integrals (inside the Bellman operator), the collocation points double as quadrature nodes with exactness for polynomials up to degree
For smooth problems, spectral approximations achieve exponential convergence: the error decreases like as we add basis functions, compared to for piecewise polynomials
The Chebyshev interpolation theorem guarantees that forcing at these carefully chosen points makes small everywhere, with well-conditioned systems and near-optimal interpolation error.
Galerkin: Make the Residual Orthogonal to the Approximation Space¶
The Galerkin method requires the residual to be orthogonal to each basis function:
To understand why this is optimal, consider the approximation space as an -dimensional subspace. If the residual is orthogonal to all basis functions, then by linearity, is orthogonal to every function in :
The residual has “zero overlap” with our approximation space—it is as “invisible” to our basis as possible. This is the defining property of orthogonal projection.
In what sense is Galerkin minimizing a norm? The dual norm of with respect to measures by its largest inner product with functions in :
The Galerkin conditions for all imply for all , so . Galerkin makes the residual “invisible” when measured against the approximation space—it minimizes the dual norm to zero.
A finite-dimensional analogy: to approximate a vector using only the -plane, the best approximation is . The error points purely in the -direction, orthogonal to the plane. The Galerkin condition generalizes this: the residual is orthogonal to the approximation space.
Galerkin requires integration to compute the conditions, making it more expensive per iteration than collocation. However, when using orthogonal polynomial bases with matching weight functions, the integrals simplify and the resulting systems are well-conditioned.
Least Squares: Minimize the Norm of the Residual¶
The most direct approach is to minimize the weighted norm of the residual:
The first-order conditions are:
This directly minimizes how far our approximation is from satisfying the equation. For the Bellman equation , this is Bellman residual minimization: we minimize .
The gradient involves differentiating the operator . For the Bellman operator with its max, this requires the Envelope Theorem (discussed in Step 4). The need to differentiate through the operator distinguishes least squares from Galerkin and collocation.
Fitted Q-Iteration: Project, Then Iterate¶
For iterative methods, there is a computationally simpler alternative to minimizing the residual directly. Fitted Q-Iteration (FQI) uses a two-step iteration:
Apply the Bellman operator to get a target:
Project the target back onto the approximation space:
The projection step solves , whose first-order conditions are . This is a standard least-squares fit of the basis to the target values. Combining these steps gives:
where denotes orthogonal projection onto with respect to the weighted inner product.
FQI does not minimize the Bellman residual directly. It projects, then iterates. FQI’s projection step uses only the gradient of with respect to (the “semi-gradient”), while Bellman residual minimization requires differentiating through (the “full gradient”). We return to this distinction when discussing temporal difference learning.
Step 4: Solve the Finite-Dimensional Problem¶
The conditions from Step 3 give us a finite-dimensional problem to solve:
Collocation: equations
Galerkin: equations
Least squares: minimize
In each case, we have equations (or first-order conditions) in unknowns . For the Bellman equation, these systems are nonlinear due to the max operator.
Computational Cost and Conditioning¶
The computational cost per iteration varies significantly across methods:
Collocation: Cheapest to evaluate since requires only pointwise evaluation (no integration). The Jacobian is also cheap: .
Galerkin and moments: More expensive due to integration. Computing requires numerical quadrature. Each Jacobian entry requires integrating .
Least squares: Most expensive when done via the objective function, which requires integrating . However, the first-order conditions reduce it to a system like Galerkin, with test functions .
For methods requiring integration, the choice of quadrature rule should match the basis. Gaussian quadrature with nodes at orthogonal polynomial zeros is efficient. When combined with collocation at those same points, the quadrature is exact for polynomials up to a certain degree. This coordination between quadrature and collocation makes orthogonal collocation effective.
The conditioning of the system depends on the choice of test functions. The Jacobian matrix has entries:
When test functions are orthogonal (or nearly so), the Jacobian tends to be well-conditioned. This is why orthogonal polynomial bases are preferred in Galerkin methods: they produce Jacobians with controlled condition numbers. Poorly chosen basis functions or collocation points can lead to nearly singular Jacobians, causing numerical instability. Orthogonal bases and carefully chosen collocation points (like Chebyshev nodes) help maintain good conditioning.
Two Main Solution Approaches¶
We have two fundamentally different ways to solve the projection equations: function iteration (exploiting fixed-point structure) and Newton’s method (exploiting smoothness). The choice depends on whether the original operator equation has contraction properties and how well those properties are preserved by the finite-dimensional approximation.
Method 1: Function Iteration (Successive Approximation)¶
When the operator equation has the form where is a contraction, the most natural approach is to iterate the operator directly:
The infinite-dimensional iteration becomes a finite-dimensional iteration in coefficient space once we choose our weighted residual method. Given a current approximation , how do we find the coefficients for the next iterate ?
Different weighted residual methods answer this differently. For collocation, we proceed in two steps:
Evaluate the operator: At each collocation point , compute what the next iterate should be: . These target values tell us what should equal at the collocation points.
Find matching coefficients: Determine so that for all . This is a linear system: .
In matrix form: , where is the collocation matrix with entries . Solving this system gives .
For Galerkin, the projection condition directly gives a system for . When is linear in its argument (as in many integral equations), this is a linear system. When is nonlinear (as in the Bellman equation), we must solve a nonlinear system at each iteration, though each solution still only involves unknowns rather than an infinite-dimensional function.
When is a contraction in the infinite-dimensional space with constant , iterating it pulls any starting function toward the unique fixed point. The hope is that the finite-dimensional operator, evaluating and projecting back onto the span of the basis functions, inherits this contraction property. When it does, function iteration converges globally from any initial guess, with each iteration reducing the error by a factor of roughly . This is computationally attractive: we only evaluate the operator and solve a linear system (for collocation) or a relatively simple system (for other methods).
However, the finite-dimensional approximation doesn’t always preserve contraction. High-order polynomial bases, in particular, can create oscillations between basis functions that amplify rather than contract errors. Even when contraction is preserved, convergence can be painfully slow when is close to 1, the “weak contraction” regime common in economic problems with patient agents ( or higher). Finally, not all operator equations naturally present themselves as contractions; some require reformulation (like ), and finding a good can be problem-specific.
Method 2: Newton’s Method¶
Alternatively, we can treat the projection equations as a rootfinding problem where for test function methods, or solve the first-order conditions for least squares. Newton’s method uses the update:
where is the Jacobian of at .
To apply this update, we must compute the Jacobian entries . For collocation, , so:
The first term is straightforward (it’s just for a linear approximation). The second term requires differentiating the operator with respect to the parameters.
When involves optimization (as in the Bellman operator ), computing this derivative appears problematic because the max operator is not differentiable. However, the Envelope Theorem resolves this difficulty.
Before reading the box below, try differentiating using the chain rule. What term involving appears? Why might this term vanish at an optimum?
With the Envelope Theorem providing a tractable way to compute Jacobians for problems involving optimization, Newton’s method becomes practical for weighted residual methods applied to Bellman equations and similar problems. The method offers quadratic convergence near the solution. Once in the neighborhood of the true fixed point, Newton’s method typically converges in just a few iterations. Unlike function iteration, it doesn’t rely on the finite-dimensional approximation preserving any contraction property, making it applicable to a broader range of problems, particularly those with high-order polynomial bases or large discount factors where function iteration struggles.
However, Newton’s method demands more from both the algorithm and the user. Each iteration requires computing and solving a full Jacobian system, making the per-iteration cost significantly higher than function iteration. The method is also sensitive to initialization: started far from the solution, Newton’s method may diverge or converge to spurious fixed points that the finite-dimensional problem introduces but the original infinite-dimensional problem lacks. When applying the Envelope Theorem, implementation becomes more complex. We must track the optimal action at each evaluation point and compute the Jacobian entries using the formula above (expected basis function values at next states under optimal actions), though the economic interpretation (tracking how value propagates through optimal decisions) often makes the computation conceptually clearer than explicit derivative calculations would be.
Comparison and Practical Recommendations¶
| Method | Convergence | Per-iteration cost | Initial guess sensitivity |
|---|---|---|---|
| Function iteration | Linear (when contraction holds) | Low | Robust |
| Newton’s method | Quadratic (near solution) | Moderate (Jacobian + solve) | Requires good initial guess |
Which method to use? When the problem has strong contraction (small , well-conditioned bases, shape-preserving approximations like linear interpolation or splines), function iteration is simple and robust. For weak contraction (large , high-order polynomials), a hybrid approach works well: run function iteration for several iterations to enter the basin of attraction, then switch to Newton’s method for rapid final convergence. When the finite-dimensional approximation destroys contraction entirely (common with non-monotone bases), Newton’s method may be necessary from the start, though careful initialization (from a coarser approximation or perturbation methods) is required.
Quasi-Newton methods like BFGS or Broyden offer a middle ground. They approximate the Jacobian using function evaluations only, avoiding explicit derivative computations while maintaining superlinear convergence. This can be useful when computing the exact Jacobian via the Envelope Theorem is expensive or when the approximation quality is acceptable.
Step 5: Verify the Solution¶
Once we have computed a candidate solution , we must verify its quality. Projection methods optimize with respect to specific criteria (specific test functions or collocation points), but we should check that the residual is small everywhere, including directions or points we did not optimize over.
Typical diagnostic checks include:
Computing using a more accurate quadrature rule than was used in the optimization
Evaluating at many points not used in the fitting process
If using Galerkin with the first basis functions, checking orthogonality against higher-order basis functions
In summary, we have established a template: parameterize the unknown function using basis functions, define a residual measuring how far from a solution we are, and impose conditions via inner products with test functions. Different test functions yield different methods: Galerkin uses the basis itself, collocation uses delta functions at chosen points, and least squares uses residual gradients. We now apply this framework to the Bellman equation.
Summary and Outlook¶
Weighted-residual methods replace an unknown function by finitely many basis coefficients and determine them by testing the residual. Collocation tests at selected points, Galerkin methods test against basis functions, and least squares minimizes an aggregate residual. Each choice specifies what it means for an approximate function to satisfy the original equation.
The framework is independent of the equation being solved. What additional stability questions arise when the residual is a Bellman residual and the underlying operator is a contraction? Approximate Bellman equations connect the projection to value and Q iteration.
Self-checks¶
Solution to Exercise 1
Against the same basis functions: for every .
Solution to Exercise 2
Collocation forces the residual to vanish at selected points. Least squares minimizes an aggregate squared residual over a sampling or weighting distribution.
- Chakraverty, S., Mahato, N. R., Karunakar, P., & Rao, T. D. (2019). Weighted Residual Methods. In Advanced Numerical and Semi-Analytical Methods for Differential Equations (pp. 25–44). John Wiley & Sons, Inc. 10.1002/9781119423461.ch3
- Atkinson, K. E., & Potra, F. A. (1987). Projection and Iterated Projection Methods for Nonlinear Integral Equations. SIAM Journal on Numerical Analysis, 24(6), 1352–1373. 10.1137/0724087