Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Weighted-Residual Methods

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 Lv=v\Bellman v = v, 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 s[0,1]s \in [0, 1] and must decide whether to stop (receive reward ss and end the episode) or continue (receive nothing, and the state redraws uniformly on [0,1][0, 1]). With discount factor γ=0.9\gamma = 0.9, the Bellman optimality equation is:

v(s)=max{s,  γ01v(s)ds}.v^*(s) = \max\left\{ s, \; \gamma \int_0^1 v^*(s') \, ds' \right\}.

The first term is the immediate payoff from stopping; the second is the discounted expected continuation value. Since the continuation value vˉ=01v(s)ds\bar{v} = \int_0^1 v^*(s') ds' is a constant (it doesn’t depend on the current state ss), the optimal policy has a threshold structure: stop if sss \geq s^* for some threshold ss^*, continue otherwise.

At the threshold, the agent is indifferent: s=γvˉs^* = \gamma \bar{v}. Computing vˉ\bar{v} by integrating vv^*:

vˉ=0sγvˉds+s1sds=sγvˉ+1(s)22.\bar{v} = \int_0^{s^*} \gamma \bar{v} \, ds' + \int_{s^*}^1 s' \, ds' = s^* \gamma \bar{v} + \frac{1 - (s^*)^2}{2}.

Substituting s=γvˉs^* = \gamma \bar{v} 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
<Figure size 800x400 with 1 Axes>

The exact value function is piecewise linear: constant at γvˉ\gamma \bar{v} below the threshold, equal to ss above it. Now suppose we want to approximate vv^* using a polynomial basis with nn terms:

v^(s;θ)=j=0n1θjsj=θ0+θ1s+θ2s2+\hat{v}(s; \theta) = \sum_{j=0}^{n-1} \theta_j s^j = \theta_0 + \theta_1 s + \theta_2 s^2 + \cdots

The residual at state ss measures how far our approximation is from satisfying the Bellman equation:

R(s;θ)=max{s,  γ01v^(s;θ)ds}v^(s;θ).R(s; \theta) = \max\left\{ s, \; \gamma \int_0^1 \hat{v}(s'; \theta) \, ds' \right\} - \hat{v}(s; \theta).

For a perfect solution, R(s;θ)=0R(s; \theta) = 0 for all s[0,1]s \in [0, 1]. But a polynomial cannot exactly represent the kink at ss^*. We must choose how to make the residual “small” across the state space.

Collocation picks nn points {s1,,sn}\{s_1, \ldots, s_n\} and requires the residual to vanish exactly there:

R(si;θ)=0,i=1,,n.R(s_i; \theta) = 0, \quad i = 1, \ldots, n.

Galerkin requires the residual to be orthogonal to each basis function:

01R(s;θ)sjw(s)ds=0,j=0,,n1.\int_0^1 R(s; \theta) s^{j} w(s) \, ds = 0, \quad j = 0, \ldots, n-1.
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
<Figure size 800x400 with 1 Axes>

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 N(f)=0\Residual(f) = 0, where N\Residual is an operator and the unknown ff is an entire function (in our case, the Bellman optimality equation Lv=v\Bellman v = v, which we can write as N(v)Lvv=0\Residual(v) \equiv \Bellman v - v = 0). Suppose we have found a candidate approximate solution f^\hat{f}. To verify it satisfies N(f^)=0\Residual(\hat{f}) = 0, we compute the residual function R(s)=N(f^)(s)R(s) = \Residual(\hat{f})(s). For a true solution, this residual should be the zero function: R(s)=0R(s) = 0 for every state ss.

How might we test whether a function is zero? One approach: sample many input points {s1,s2,,sm}\{s_1, s_2, \ldots, s_m\}, check whether R(si)=0R(s_i) = 0 at each, and summarize the results into a single scalar test by computing a weighted sum i=1mwiR(si)\sum_{i=1}^m w_i R(s_i) with weights wi>0w_i > 0. If RR is zero everywhere, this sum is zero. If RR is nonzero somewhere, we can choose points and weights to make the sum nonzero. For vectors in finite dimensions, the inner product r,y=i=1nriyi\langle \mathbf{r}, \mathbf{y} \rangle = \sum_{i=1}^n r_i y_i implements exactly this idea: it tests r\mathbf{r} by weighting and summing. Indeed, a vector rRn\mathbf{r} \in \mathbb{R}^n equals zero if and only if r,y=0\langle \mathbf{r}, \mathbf{y} \rangle = 0 for every vector yRn\mathbf{y} \in \mathbb{R}^n. To see why, suppose r0\mathbf{r} \neq \mathbf{0}. Choosing y=r\mathbf{y} = \mathbf{r} gives r,r=r2>0\langle \mathbf{r}, \mathbf{r} \rangle = \|\mathbf{r}\|^2 > 0, contradicting the claim that all inner products vanish.

The same principle extends to functions. A function RR equals the zero function if and only if its “inner product” with every “test function” pp vanishes:

R=0if and only ifR,pw=SR(s)p(s)w(s)ds=0for all test functions p,R = 0 \quad \text{if and only if} \quad \langle R, p \rangle_w = \int_{\mathcal{S}} R(s) p(s) w(s) ds = 0 \quad \text{for all test functions } p,

where w(s)>0w(s) > 0 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 RR is not the zero function, there must be some region where R(s)0R(s) \neq 0. We can then choose a test function pp that is nonzero in that same region (for instance, p(s)=R(s)p(s) = R(s) itself), which will produce R,pw=R(s)p(s)w(s)ds>0\langle R, p \rangle_w = \int R(s) p(s) w(s) ds > 0, witnessing that RR is nonzero. Conversely, if RR is the zero function, then R,pw=0\langle R, p \rangle_w = 0 for any test function pp.

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.

This transforms the pointwise condition “R(s)=0R(s) = 0 for all ss” (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 {p1,,pn}\{p_1, \ldots, p_n\} and use them to construct nn conditions that we can actually compute.

From Variational Conditions to Optimization

Making a residual “small” is an optimization problem. We want to find θ\theta that minimizes R(;θ)\lVert R(\cdot; \theta) \rVert for some norm. Different methods correspond to different choices of norm:

The first-order conditions for these optimization problems take the form R,pjw=0\langle R, p_j \rangle_w = 0 for appropriate “test functions” pjp_j. 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

N(f)=0,\Residual(f) = 0,

where N:B1B2\Residual: B_1 \to B_2 is a continuous operator between complete normed vector spaces B1B_1 and B2B_2. For the Bellman equation, we have N(v)=Lvv\Residual(v) = \Bellman v - v, so that solving N(v)=0\Residual(v) = 0 is equivalent to finding the fixed point v=Lvv = \Bellman v.

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 {φ1,,φn}\{\varphi_1, \ldots, \varphi_n\}, commonly polynomials (Chebyshev, Legendre), though other function classes (splines, radial basis functions, neural networks) are possible, and search for coefficients θ=(θ1,,θn)\theta = (\theta_1, \ldots, \theta_n) in Rn\mathbb{R}^n. 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 Φ={φ1,φ2,,φn}\Phi = \{\varphi_1, \varphi_2, \ldots, \varphi_n\} and approximating the unknown function as a linear combination:

f^(x)=i=1nθiφi(x).\hat{f}(x) = \sum_{i=1}^n \theta_i \varphi_i(x).

The choice of basis functions φi\varphi_i is problem-dependent. Common choices include:

The number of basis functions nn determines the flexibility of our approximation. In practice, we start with small nn and increase it until the approximation quality is satisfactory. The only unknowns now are the coefficients θ=(θ1,,θn)\theta = (\theta_1, \ldots, \theta_n).

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 f^(x;θ)\hat{f}(x; \theta) with parameters θ\theta 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 ff with f^\hat{f}, the operator N\Residual will generally not vanish exactly. Instead, we obtain a residual function:

R(x;θ)=N(f^(;θ))(x).R(x; \theta) = \Residual(\hat{f}(\cdot; \theta))(x).

This residual measures how far our candidate solution is from satisfying the equation at each point xx. 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 nn scalar conditions on θ\theta. The choice of conditions determines the method:

MethodResidual criterionConditions (nn equations)
Least squaresRw2=R(x;θ)2w(x)dx\displaystyle\lVert R \rVert_w^2 = \int R(x; \theta)^2 w(x) dxRRθjwdx=0\displaystyle\int R \cdot \frac{\partial R}{\partial \theta_j} \, w \, dx = 0, j=1,,nj = 1, \ldots, n
GalerkinRV\lVert R \rVert_{\mathcal{V}^*} (dual norm of approx. space)R(x;θ)φj(x)w(x)dx=0\displaystyle\int R(x; \theta) \varphi_j(x) w(x) dx = 0, j=1,,nj = 1, \ldots, n
CollocationExact pointwise satisfactionR(xi;θ)=0R(x_i; \theta) = 0, i=1,,ni = 1, \ldots, n

Each criterion yields nn equations in the nn unknowns θ1,,θn\theta_1,\ldots,\theta_n.

Collocation: Make the Residual Zero at Selected Points

The simplest approach is to choose nn points {x1,,xn}\{x_1, \ldots, x_n\} and require the residual to vanish exactly at each:

R(xi;θ)=0,i=1,,n.R(x_i; \theta) = 0, \quad i = 1, \ldots, n.

This gives nn equations for nn unknowns. Collocation is computationally attractive because it avoids integration entirely—we only evaluate RR at discrete points. The resulting system is:

N(f^(;θ))(xi)=0,i=1,,n.\Residual(\hat{f}(\cdot; \theta))(x_i) = 0, \quad i = 1, \ldots, n.

For a linear operator, this is a linear system; for the Bellman equation, it is nonlinear due to the max.

Verify for yourself: with n=2n = 2 collocation points and n=2n = 2 basis functions, the system Φθ=t\boldsymbol{\Phi}\theta = t is a 2×22 \times 2 linear system. What must be true about the collocation matrix Φ\boldsymbol{\Phi} 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 nn-th orthogonal polynomial in a family (Chebyshev, Legendre, etc.). For Chebyshev polynomials T0,T1,,Tn1T_0, T_1, \ldots, T_{n-1}, we place collocation points at the zeros of Tn(x)T_n(x). These points are also optimal nodes for Gauss quadrature, so:

The Chebyshev interpolation theorem guarantees that forcing R(xi;θ)=0R(x_i; \theta) = 0 at these carefully chosen points makes R(x;θ)R(x; \theta) 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:

SR(x;θ)φi(x)w(x)dx=0,i=1,,n.\int_{\mathcal{S}} R(x; \theta) \varphi_i(x) w(x) dx = 0, \quad i = 1, \ldots, n.

To understand why this is optimal, consider the approximation space V=span{φ1,,φn}\mathcal{V} = \text{span}\{\varphi_1, \ldots, \varphi_n\} as an nn-dimensional subspace. If the residual RR is orthogonal to all basis functions, then by linearity, RR is orthogonal to every function in V\mathcal{V}:

R,gw=R,i=1nciφiw=i=1nciR,φiw=0for all gV.\langle R, g \rangle_w = \left\langle R, \sum_{i=1}^n c_i \varphi_i \right\rangle_w = \sum_{i=1}^n c_i \langle R, \varphi_i \rangle_w = 0 \quad \text{for all } g \in \mathcal{V}.

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 RR with respect to V\mathcal{V} measures RR by its largest inner product with functions in V\mathcal{V}:

RV=supgVgw=1R,gw.\lVert R \rVert_{\mathcal{V}^*} = \sup_{\substack{g \in \mathcal{V} \\ \lVert g \rVert_w = 1}} \lvert \langle R, g \rangle_w \rvert.

The Galerkin conditions R,φjw=0\langle R, \varphi_j \rangle_w = 0 for all jj imply R,gw=0\langle R, g \rangle_w = 0 for all gVg \in \mathcal{V}, so RV=0\lVert R \rVert_{\mathcal{V}^*} = 0. 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 vR3\mathbf{v} \in \mathbb{R}^3 using only the xyxy-plane, the best approximation is v^=(v1,v2,0)\hat{\mathbf{v}} = (v_1, v_2, 0). The error r=vv^=(0,0,v3)\mathbf{r} = \mathbf{v} - \hat{\mathbf{v}} = (0, 0, v_3) points purely in the zz-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 L2L^2 Norm of the Residual

The most direct approach is to minimize the weighted L2L^2 norm of the residual:

minθSR(x;θ)2w(x)dx.\min_\theta \int_{\mathcal{S}} R(x; \theta)^2 w(x) dx.

The first-order conditions are:

SR(x;θ)R(x;θ)θjw(x)dx=0,j=1,,n.\int_{\mathcal{S}} R(x; \theta) \frac{\partial R(x; \theta)}{\partial \theta_j} w(x) dx = 0, \quad j = 1, \ldots, n.

This directly minimizes how far our approximation is from satisfying the equation. For the Bellman equation R=Lv^v^R = \Bellman\hat{v} - \hat{v}, this is Bellman residual minimization: we minimize Lv^v^w2\lVert \Bellman\hat{v} - \hat{v} \rVert_w^2.

The gradient Rθj\frac{\partial R}{\partial \theta_j} involves differentiating the operator N\Residual. 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:

  1. Apply the Bellman operator to get a target: fk=Lv^kf_k = \Bellman \hat{v}_k

  2. Project the target back onto the approximation space: v^k+1=argminθv^(;θ)fkw2\hat{v}_{k+1} = \arg\min_\theta \lVert \hat{v}(\cdot; \theta) - f_k \rVert_w^2

The projection step solves minθv^fkw2\min_\theta \lVert \hat{v} - f_k \rVert_w^2, whose first-order conditions are v^fk,φjw=0\langle \hat{v} - f_k, \varphi_j \rangle_w = 0. This is a standard least-squares fit of the basis to the target values. Combining these steps gives:

v^k+1=ΠwLv^k,\hat{v}_{k+1} = \Pi_w \, \Bellman \hat{v}_k,

where Πw\Pi_w denotes orthogonal projection onto span{φj}\text{span}\{\varphi_j\} with respect to the weighted inner product.

FQI does not minimize the Bellman residual Lv^v^2\lVert \Bellman\hat{v} - \hat{v} \rVert^2 directly. It projects, then iterates. FQI’s projection step uses only the gradient of v^\hat{v} with respect to θ\theta (the “semi-gradient”), while Bellman residual minimization requires differentiating through L\Bellman (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:

In each case, we have nn equations (or first-order conditions) in nn unknowns θ1,,θn\theta_1, \ldots, \theta_n. 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:

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:

Jij=Piθj=R(;θ)θj,piw.J_{ij} = \frac{\partial P_i}{\partial \theta_j} = \left\langle \frac{\partial R(\cdot; \theta)}{\partial \theta_j}, p_i \right\rangle_w.

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 f=Tff = \Contraction f where T\Contraction is a contraction, the most natural approach is to iterate the operator directly:

f^(k+1)=Tf^(k).\hat{f}^{(k+1)} = \Contraction \hat{f}^{(k)}.

The infinite-dimensional iteration becomes a finite-dimensional iteration in coefficient space once we choose our weighted residual method. Given a current approximation f^(k)(x;θ(k))\hat{f}^{(k)}(x; \theta^{(k)}), how do we find the coefficients θ(k+1)\theta^{(k+1)} for the next iterate f^(k+1)\hat{f}^{(k+1)}?

Different weighted residual methods answer this differently. For collocation, we proceed in two steps:

  1. Evaluate the operator: At each collocation point xix_i, compute what the next iterate should be: ti(k)=(Tf^(k))(xi)t_i^{(k)} = (\Contraction \hat{f}^{(k)})(x_i). These nn target values tell us what f^(k+1)\hat{f}^{(k+1)} should equal at the collocation points.

  2. Find matching coefficients: Determine θ(k+1)\theta^{(k+1)} so that f^(k+1)(xi;θ(k+1))=ti(k)\hat{f}^{(k+1)}(x_i; \theta^{(k+1)}) = t_i^{(k)} for all ii. This is a linear system: jθj(k+1)φj(xi)=ti(k)\sum_j \theta_j^{(k+1)} \varphi_j(x_i) = t_i^{(k)}.

In matrix form: Φθ(k+1)=t(k)\boldsymbol{\Phi} \theta^{(k+1)} = t^{(k)}, where Φ\boldsymbol{\Phi} is the collocation matrix with entries Φij=φj(xi)\Phi_{ij} = \varphi_j(x_i). Solving this system gives θ(k+1)=Φ1t(k)\theta^{(k+1)} = \boldsymbol{\Phi}^{-1} t^{(k)}.

For Galerkin, the projection condition f^(k+1)Tf^(k+1),φiw=0\langle \hat{f}^{(k+1)} - \Contraction \hat{f}^{(k+1)}, \varphi_i \rangle_w = 0 directly gives a system for θ(k+1)\theta^{(k+1)}. When T\Contraction is linear in its argument (as in many integral equations), this is a linear system. When T\Contraction is nonlinear (as in the Bellman equation), we must solve a nonlinear system at each iteration, though each solution still only involves nn unknowns rather than an infinite-dimensional function.

When T\Contraction is a contraction in the infinite-dimensional space with constant γ<1\gamma < 1, iterating it pulls any starting function toward the unique fixed point. The hope is that the finite-dimensional operator, evaluating T\Contraction 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 γ\gamma. 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 γ\gamma is close to 1, the “weak contraction” regime common in economic problems with patient agents (γ0.95\gamma \approx 0.95 or higher). Finally, not all operator equations naturally present themselves as contractions; some require reformulation (like f=fαN(f)f = f - \alpha \Residual(f)), and finding a good α\alpha can be problem-specific.

Method 2: Newton’s Method

Alternatively, we can treat the projection equations as a rootfinding problem G(θ)=0G(\theta) = 0 where Gi(θ)=Pi(θ)G_i(\theta) = P_i(\theta) for test function methods, or solve the first-order conditions for least squares. Newton’s method uses the update:

θ(k+1)=θ(k)JG(θ(k))1G(θ(k)),\theta^{(k+1)} = \theta^{(k)} - J_G(\theta^{(k)})^{-1} G(\theta^{(k)}),

where JG(θ)J_G(\theta) is the Jacobian of GG at θ\theta.

To apply this update, we must compute the Jacobian entries Jij=GiθjJ_{ij} = \frac{\partial G_i}{\partial \theta_j}. For collocation, Gi(θ)=f^(xi;θ)(Tf^(;θ))(xi)G_i(\theta) = \hat{f}(x_i; \theta) - (\Contraction \hat{f}(\cdot; \theta))(x_i), so:

Giθj=f^(xi;θ)θj(Tf^(;θ))(xi)θj.\frac{\partial G_i}{\partial \theta_j} = \frac{\partial \hat{f}(x_i; \theta)}{\partial \theta_j} - \frac{\partial (\Contraction \hat{f}(\cdot; \theta))(x_i)}{\partial \theta_j}.

The first term is straightforward (it’s just φj(xi)\varphi_j(x_i) for a linear approximation). The second term requires differentiating the operator T\Contraction with respect to the parameters.

When T\Contraction involves optimization (as in the Bellman operator Lv=maxa{r(s,a)+γE[v(s)]}\Bellman v = \max_a \{r(s,a) + \gamma \mathbb{E}[v(s')]\}), 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 v(θ)=maxxf(x,θ)v(\theta) = \max_x f(x, \theta) using the chain rule. What term involving x/θ\partial x^*/\partial \theta 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
MethodConvergencePer-iteration costInitial guess sensitivity
Function iterationLinear (when contraction holds)LowRobust
Newton’s methodQuadratic (near solution)Moderate (Jacobian + solve)Requires good initial guess

Which method to use? When the problem has strong contraction (small γ\gamma, well-conditioned bases, shape-preserving approximations like linear interpolation or splines), function iteration is simple and robust. For weak contraction (large γ\gamma, 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 f^\hat{f}, we must verify its quality. Projection methods optimize f^\hat{f} 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:

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: ϕi,Lvv=0\langle \phi_i,\Bellman v-v\rangle=0 for every ii.

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.

References
  1. 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
  2. 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