Chapters Chapter 2--Chapter 6 operated in discrete time, where the equilibrium conditions take the form of expectational (Euler) equations. We now shift to continuous time, where the optimality conditions are partial differential equations -- Hamilton--Jacobi--Bellman (HJB) equations for optimal control and Kolmogorov forward equations for wealth distributions. Physics-Informed Neural Networks (PINNs) approximate the solution of such PDEs by minimizing the PDE residual at collocation points, using automatic differentiation to compute the required derivatives Sirignano & Spiliopoulos, 2018Raissi et al., 2019. The PINN loss is structurally analogous to the DEQN loss of Chapter Chapter 2, but instead of time-stepping a fixed-point iteration we solve a single PDE globally over the state space. This chapter develops the PINN methodology from simple ODEs through boundary-condition strategies to the HJB equation for consumption--savings problems, with applications to macro-finance.
7.1From DEQNs to PINNs: Discrete vs. Continuous Time¶
Many frontier models in macroeconomics and finance are written in continuous time. Examples include Hamilton--Jacobi--Bellman (HJB) equations for optimal control, Kolmogorov forward equations for wealth distributions, and Black--Scholes PDEs for asset pricing. The DEQN methodology from Chapters Chapter 2--Chapter 3 handles discrete-time equilibrium conditions. Its continuous-time analogue relies on derivatives of the network with respect to its inputs, which automatic differentiation provides directly.
The resulting framework, known as Physics-Informed Neural Networks (PINNs), was introduced by Raissi et al. (2019). In economics and finance, continuous-time models governed by HJB and related PDEs arise naturally in asset pricing under climate uncertainty Barnett et al., 2020, portfolio choice Duarte et al., 2024, and heterogeneous-agent economies with aggregate shocks Gopalakrishna, 2024. Duarte et al. (2024) apply machine-learning methods to continuous-time finance problems, while Gopalakrishna (2024) develops the ALIENs framework for solving continuous-time economies with deep learning. PINNs provide a natural and scalable computational framework for such problems. Figure Figure 7.1 summarizes the discrete-time DEQN template and its continuous-time PINN analogue.
Figure 7.1:Discrete-time DEQNs and continuous-time PINNs use the same residual-minimization principle with different mathematical residuals. DEQNs minimize algebraic equilibrium conditions such as Euler-equation errors evaluated along simulated states, while PINNs minimize PDE and boundary residuals evaluated at collocation points using derivatives of the network with respect to its inputs.
7.2The PINN Loss and Automatic Differentiation for PDEs¶
7.2.0.1Prerequisites in one paragraph.¶
A few terms from PDE numerics recur throughout the chapter and deserve to be fixed in advance. Collocation points are interior evaluation points at which the PDE residual is enforced; they do not need to lie on a Cartesian grid, and in high dimensions they are typically drawn at random or from a low-discrepancy sequence. The strong form minimizes the residual point-wise and requires the network’s activation to be at least if the differential operator is of order . The weak form integrates the residual against test functions, which tolerates rougher solutions but is rarely needed for the PDEs in this chapter. We assume throughout that each problem is well-posed (existence, uniqueness, and continuous dependence on data); proving well-posedness for a particular HJB or KFE is part of the PDE literature, not of this course.
Given a PDE on a domain with boundary conditions on , the PINN loss is:
The derivatives appearing in are computed algorithmically via automatic differentiation[1] (e.g., torch.autograd.grad in PyTorch), up to floating-point precision and without any finite-difference approximation. This removes finite-difference truncation error in derivative terms and is a major practical advantage in high dimensions because no state-space grid is required. Remaining error sources are function-approximation error, optimization error, and collocation sampling error.
7.2.0.2Activation function requirements.¶
The choice of activation function is particularly important for classical strong-form PINNs that compute high-order derivatives via automatic differentiation. If the PDE operator involves -th order derivatives, the network’s activation function must be at least for the strong residual to be well-defined. is only and its second derivative is zero almost everywhere (and undefined at the kink), so a ReLU network is not suitable for the strong form of a second-order PDE. For second-order PDEs (HJB, Black--Scholes, Poisson), one should use activations such as , Swish, or softplus. This requirement stands in contrast to the supervised setting, where ReLU is the default. The trade-off is real: smooth saturating activations propagate gradients more slowly than ReLU on the same architecture (the upper plateau of has near-zero slope), so PINNs typically need wider networks or more iterations to reach the same training loss as a comparable supervised ReLU network. In practice this is the price of having well-defined second derivatives. Note that the limitation is specific to strong-form auto-differentiation PINNs: weak/variational formulations and methods that handle nonsmooth solutions explicitly can still use ReLU activations, since high-order derivatives never need to be differentiated point-wise. More broadly, PINN optimization can suffer from gradient pathologies across loss terms, which is why adaptive loss balancing is often beneficial Wang et al., 2021Bischof & Kraus, 2025.
7.2.1A Concrete Example: Solving a 1D ODE with a PINN¶
To build intuition, consider the boundary value problem
whose analytical solution is . Approximate the unknown function by a raw neural network , with no boundary information built in. The strong-form residual is
where is obtained by two applications of torch.autograd.grad. The boundary conditions are then added to the loss as a penalty term -- the soft enforcement strategy:
with collocation points drawn uniformly from and a weight on the boundary term. Building the boundary conditions directly into the network output instead -- the hard enforcement alternative, which removes the term entirely -- is taken up in Section 7.3.
Figure 7.2:PINN solution of the 1D ODE on with and the soft-penalty loss (7.4). The analytical solution (solid blue) is recovered to plotting accuracy by the converged network (dotted green); the dashed red curve illustrates a typical early-training iterate, which still misses the endpoints because the boundary penalty is enforced only approximately. Tick marks on the -axis are the uniformly drawn collocation points. The curves above are TikZ illustrations rather than direct exports. Notebook lecture_11_01_ODE_PINN_ZeroBCs runs exactly this experiment; notebook lecture_11_02_ODE_PINN_SoftVsHardBCs then contrasts the soft penalty against the hard trial-solution construction of Section 7.3 on a non-zero-BC variant.
Figure Figure 7.2 shows this calculation graphically. This simple example illustrates the key ingredients of every PINN: (i) a neural network that approximates the unknown function, (ii) automatic differentiation to compute derivatives, (iii) a loss function built from the PDE residual (plus, here, a boundary penalty), and (iv) collocation points sampled from the domain interior. The same machinery extends directly to PDEs in two or more dimensions, as we demonstrate in the following applications.
7.3Boundary Conditions: Soft vs. Hard Enforcement¶
The treatment of boundary conditions is a critical design choice in PINNs.
7.3.0.1Soft enforcement.¶
Boundary conditions are penalized as an additional loss term, weighted by . The difficulty is that must be tuned: too small and the BCs are violated; too large and the optimizer ignores the PDE interior. Figure Figure 7.3 sketches the two failure modes and the compromise regime in between.
Figure 7.3:Failure modes of soft boundary-condition enforcement on a Dirichlet problem with , . Left: the BC penalty weight is too small, so the optimizer minimizes the interior PDE residual but lets the candidate solution miss both endpoints (visible as the “gap” at ). Right: is too large, so the network nails the boundary values but distorts the interior, producing a wiggly profile with PDE residual error against the affine reference (dashed grey). Centre: a balanced approximately satisfies both objectives, but the right-shaped value depends on the network, the PDE, and the geometry, and is not known a priori. This trade-off motivates the hard-enforcement construction below, which removes the boundary loss term entirely.
7.3.0.2Hard enforcement.¶
A trial solution is constructed that satisfies the boundary conditions by construction:
where is an anchor function satisfying the BCs exactly, and is a mask function that vanishes at the boundary. For Dirichlet BCs , , one may choose and . Figure Figure 7.4 visualizes this anchor-plus-mask decomposition for non-zero endpoint data.
Figure 7.4:Hard boundary-condition decomposition for the trial solution with Dirichlet data , . Left: anchor matches the boundary values exactly. Centre: mask times network, with mask , which vanishes at regardless of . Right: their sum (solid green) is a candidate solution that satisfies both BCs by construction; the dashed red line is the affine anchor for visual reference. Training loss reduces to the interior PDE residual alone.
Hard enforcement eliminates the boundary loss term entirely, reducing the number of hyperparameters and improving accuracy near the boundaries. The trade-off is real, however: because multiplies the network output by a mask that vanishes on , the input-gradient inherits a factor of near the boundary and is thus damped by construction. When the true solution exhibits a steep boundary layer (e.g., a Hamilton--Jacobi--Bellman equation at the borrowing constraint, see Section 8.4), the network must compensate by making itself locally large, which can slow convergence. In short: hard BCs trade boundary-loss tunability for vanishing input gradients at , and the trade is favorable for smooth Dirichlet problems but less obviously so for problems with sharp boundary features.
7.3.0.3A worked 1D instance.¶
As a concrete instantiation, return to the simple ODE on with , , whose analytical solution is . A trial solution that builds in both endpoints is
which has the anchor-plus-mask form (7.5): the anchor matches the boundary data (, ) and the mask vanishes at both endpoints, so and hold exactly for any network output, and the loss reduces to the interior PDE residual alone,
with obtained by two applications of torch.autograd.grad and collocation points drawn uniformly from .
Figure 7.5:PINN solution of the 1D ODE on with the hard-BC trial solution (7.6). The analytical solution (solid blue) is recovered to plotting accuracy by the converged network (dotted green); the dashed red curve illustrates a typical early-training iterate. Tick marks on the -axis are the uniformly drawn collocation points. The curves above are TikZ illustrations rather than direct exports. Notebook lecture_11_02_ODE_PINN_SoftVsHardBCs contrasts this hard-trial-solution construction with the soft-penalty alternative on a non-zero-BC variant.
Figure Figure 7.5 confirms that the converged trial solution recovers to plotting accuracy, with the boundary values exact by construction; contrast the early-training iterate of Figure Figure 7.2, which still misses the endpoints under the soft penalty.
7.3.0.4Transfinite interpolation for 2D domains.¶
The 1D hard-enforcement idea () extends naturally to rectangular 2D domains, but the anchor function must now interpolate prescribed boundary data along entire edges, not just at two endpoints. The classical technique for this is transfinite interpolation (also known as Gordon--Coons blending): it constructs a function over the rectangle that exactly matches given boundary curves, in much the same way that bilinear interpolation matches four corner values, except that here we match four continuous edge functions rather than four discrete values.
Consider a rectangular domain with Dirichlet boundary data (left edge, ), (right edge, ), (bottom edge, ), and (top edge, ). Introduce the normalized coordinates and . The idea is to blend the four edge functions using linear weights, then correct for the corners that get counted twice.
Step 1, Interpolate in : The function matches the left and right edges exactly for every , but says nothing about the top and bottom edges.
Step 2, Interpolate in : Similarly, matches the bottom and top edges exactly for every .
Step 3, Add and correct. Summing these two would double-count the corner values (e.g., and both contribute at ). We subtract a bilinear interpolant through the four corner values to compensate. The result is the blending (anchor) function:
where , etc., are the four corner values. These values must be consistent across the two edges that meet at each corner (e.g., the value of at must equal the value of at ); otherwise the corner-correction bilinear cancels imperfectly and does not match any of the four edges exactly at the offending corner. Under consistent corner data, matches all four edge functions exactly by construction.
The mask function must vanish on all four edges so that the network can modify the interior without disturbing the boundaries:
Note that whenever or , i.e., on every edge of the rectangle. The hard-enforced trial solution is then:
On any boundary edge, and reduces to , which matches the prescribed data. In the interior, and the network is free to learn whatever shape is needed to satisfy the PDE. This construction satisfies all four Dirichlet conditions exactly for any network output .
7.3.12D Poisson Benchmark¶
As a pedagogical 2D benchmark, the accompanying notebook lecture_11_03_PDE_PINN_Poisson2D solves a Poisson equation on the unit square,
with manufactured solution , yielding and non-homogeneous Dirichlet data , , , . (Some PDE references prefer the standard-elliptic convention ; switching to that form flips the sign of but leaves the boundary data and the network architecture unchanged.) Because vanishes on , the polynomial part already matches all four edges (and their corner values) exactly, so it serves as the transfinite-interpolation anchor (the corner-consistency requirement of Section 7.3 is automatic here). The mask vanishes on every edge, and the hard-enforced trial solution satisfies all Dirichlet conditions by construction; the network is trained on the interior PDE residual alone. In the reference notebook configuration, the verification gate is a mode-dependent relative- error against the manufactured solution on a test grid (disabled in the smoke CI run, with progressively tighter bounds in teaching and production), computed for a modest network and a few thousand collocation points; the exact numbers depend on seed, hardware, optimizer settings, and the collocation sample. This benchmark is the clean 2D extension of the 1D ODE example and a useful bridge before turning to economic applications, and it exercises the full hard-BC transfinite-interpolation machinery on non-zero edge data rather than collapsing to the trivial case.
7.4Common PINN Failure Modes and Remedies¶
In practice, PINN training often fails for optimization reasons rather than approximation capacity. Table Table 7.1 lists the most common pathologies and practical remedies.
Table 7.1:Common PINN failure modes and practical remedies. The main implementation lesson is to monitor loss components separately: a small total loss can hide boundary violations, interior residual spikes, or gradient imbalance across terms.
| Symptom | Typical cause | Practical remedy |
|---|---|---|
| Large boundary violations | Soft BC penalties underweighted or unstable | Prefer hard BC trial solutions when possible; otherwise use adaptive loss balancing (e.g., ReLoBRaLo). |
| Good BC fit, poor interior PDE fit | Boundary penalties overweighted | Decrease BC weights or rebalance losses dynamically. |
| Residual spikes in narrow regions | Collocation undercoverage (boundary layers / kinks) | Use residual-based adaptive resampling, Sobol/LHS points, and local point refinement. |
| Slow or stalled optimization | Gradient imbalance across loss terms; or initialization in a basin disconnected from the true solution | Normalize loss components and monitor per-term gradients; use adaptive balancing schemes Wang et al., 2021Bischof & Kraus, 2025; restart with different seeds or warm-start from a coarser solver if the loss plateaus far from any plausible solution. |
| Optimizer stuck on a symmetric / structureless ansatz | Initialization too symmetric to represent an asymmetric solution; gradient updates preserve the symmetry | Break the symmetry explicitly: asymmetric weight initialization, an auxiliary symmetry-breaking input feature, or a short pre-training pass that nudges the ansatz toward the correct shape. |
| Oscillatory solution near payoff kink | Spectral bias and non-smooth target geometry | Increase sampling density near kink and split domain if needed; use problem-specific transforms. |
The penultimate row above is folklore in computational quantum chemistry, where solvers routinely ship dedicated symmetry-breaking modules because a symmetric initial guess is preserved exactly under gradient training; the analogous trap shows up in PINNs whenever the true solution lacks a symmetry that the architecture happens to enforce.
For the course applications, a robust default stack is: smooth activation ( or Swish), hard BCs when analytically available, adaptive loss balancing, and adaptive collocation near high-residual regions.
7.5The Deep Galerkin Method (DGM) Architecture¶
The plain MLP used in the examples so far -- and, below, for the cake-eating HJB -- is sufficient for low-dimensional PDEs with smooth solutions, but its expressive bottleneck shows up in two regimes: (i) genuinely high-dimensional state spaces (where curse-of-dimensionality effects compound across layers), and (ii) PDEs with sharp internal features such as boundary layers, wave fronts, or kinks at policy switches. The Deep Galerkin Method addresses both by adding LSTM-style gates and skip connections from the input to every layer, so that the network can carry input information forward unchanged through depth and route it past intermediate transformations. In the 1D problems studied so far, an MLP and a DGM block train to comparable accuracy and the MLP is preferred for transparency; the architectural complexity pays off as dimension grows or sharp features appear. Table Table 7.2 gives a qualitative comparison across the problem classes treated in this chapter; the chapter’s exercises invite a concrete benchmark of the two architectures on the same PDE.
Table 7.2:Qualitative MLP vs. DGM comparison across the problem classes of this chapter. “Comparable” means the two architectures train to similar final residual at similar wall time; “preferred” indicates which one a practitioner should reach for first. A quantitative benchmark on a fixed pair (residual, wall time, parameters) is the natural project extension and is not run here.
| Problem class | MLP | DGM | Where DGM helps |
|---|---|---|---|
| 1D ODE (Section 7.3) | comparable | comparable | not in 1D smooth problems; MLP preferred for transparency |
| 2D Poisson (Section 7.3) | comparable | comparable | marginally, on stiff sources |
| Cake-eating HJB (Section 7.6) | preferred | comparable | MLP wins when hard BCs already kill the boundary loss; DGM wins if kinks at policy-switching points dominate |
| Black--Scholes (Section 7.8) | adequate | cleaner near kink | sharp payoff kink at ; DGM gates absorb local geometry better |
| High-dim HJB () | curse of dim. visible | preferred | input-skip connections retain raw coordinates at every depth, mitigating expressivity loss across layers |
For high-dimensional PDEs, Sirignano & Spiliopoulos (2018) introduced the Deep Galerkin Method (DGM), an architecture with LSTM-style gating Hochreiter & Schmidhuber, 1997 and skip connections from the input layer to every hidden layer reminiscent of Highway Networks Srivastava et al., 2015 (the immediate precursor of ResNets, in which a learned gate controls how much of the previous representation is carried forward unchanged versus transformed).[2] A related deep BSDE-based formulation was introduced by E et al. (2017) (E--Han--Jentzen) and developed in the companion paper of Han et al. (2018) (Han--Jentzen--E). An accessible exposition of DGM together with several PDE applications is given by Al-Aradi et al. (2018), which also introduces the gate naming convention adopted below. The original DGM architecture of Sirignano & Spiliopoulos (2018) uses four gates at each layer :
and the state update is:
Note that this formulation uses two separate gates: controls how much of the previous state to retain, while scales the new candidate . Because and are independent in the original Sirignano--Spiliopoulos formulation, the two coefficients need not sum to one. A simpler GRU-style variant Cho et al., 2014 collapses the two gates into a single convex combination , where the coefficients sum to one; in practice, both variants perform comparably on the PDE benchmarks in this course. The gate controls which parts of the previous state are relevant for computing the candidate . The gate naming convention used here follows Al-Aradi et al. (2018); in GRU terminology, corresponds to the update gate and to the reset gate. The input enters every layer through the matrices, providing skip connections that ensure input information is available at every depth. This gating mechanism, directly analogous to LSTM recurrent networks, helps the DGM architecture learn functions that depend sensitively on the input coordinates, a common feature of PDE solutions near boundary layers. Figure Figure 7.6 shows the resulting feed-forward architecture.
Figure 7.6:The DGM (Deep Galerkin Method) architecture of Sirignano & Spiliopoulos (2018). The input feeds the first layer through a standard forward path (solid arrows) and is, in addition, routed to every subsequent DGM block via skip connections (dashed arrows), so each layer can see directly as well as the running hidden state. Each DGM block combines with the hidden state through update, forget, and relevance gates (see body text), in the spirit of LSTM/GRU recurrences applied across depth rather than time.
7.5.0.1Stationary vs. evolutionary PDEs.¶
The PINN framework applies uniformly to both stationary PDEs, where the unknown depends only on state variables (), and evolutionary PDEs, where time enters as an additional input (). The network architecture is identical in both cases: only the input dimension changes. The HJB equation below is stationary: the value function depends on a single state variable. The Black--Scholes PDE of Section Section 7.8 is evolutionary: depends on both the asset price and time to maturity.
7.6Application: HJB Equation and the Cake-Eating Problem¶
Consider a household with wealth that chooses a consumption stream to maximize discounted lifetime utility:
where is the subjective discount rate, () is the coefficient of relative risk aversion (CRRA), and is the interest rate on wealth. The budget constraint says that wealth grows at rate minus consumption; we call this the “cake-eating” problem in a loose sense because the household consumes out of a single finite stock of wealth. Strictly speaking, the textbook cake-eating problem has (the cake does not grow); the variant solved here is the consumption--savings problem with deterministic returns, and Exercise 7.3 traces the limit explicitly. The dynamic-programming perspective is classical in economics; see Stokey et al. (1989) for the standard textbook treatment. Conceptually, this is the same recursive optimization that produced the discrete-time Bellman equations of Chapters Chapter 2--Chapter 3; the only difference is that the household now optimizes over a continuous time grid, so the resulting optimality condition is a partial differential equation (the HJB) rather than an algebraic Euler equation. The derivation below makes this link precise.
7.6.0.1Deriving the HJB equation.¶
Define the value function as the maximum attainable lifetime utility starting from wealth :
Since the problem is stationary (no explicit time dependence in the return or the law of motion), depends only on the current state , not on calendar time.
To derive the HJB equation, apply the principle of optimality: over a short interval , the household chooses optimally and then continues optimally from the resulting state . This gives:
Now expand both the discount factor and the value function to first order in :
Substituting (7.17) and (7.18) into (7.16):
Expanding the product and dropping terms of order :
Cancel from both sides, divide by , and let :
This is the Hamilton--Jacobi--Bellman (HJB) equation. The left-hand side is the “cost of holding wealth ” (the required return ). The right-hand side is the “benefit”: instantaneous utility from consuming , plus the capital gain from the change in wealth.
7.6.0.2First-order condition and optimal consumption.¶
The maximization in (7.21) is over with the objective being concave in (since ). Differentiating the term inside the braces with respect to and setting to zero:
The economic content is intuitive: the marginal utility of consumption equals the marginal value of wealth . A higher (wealth is more valuable) implies lower optimal consumption.
7.6.0.3Analytical solution.¶
The HJB (7.21) with the FOC (7.22) substituted in becomes a nonlinear ODE in . To solve it, conjecture for some constant . Then , and from the FOC (7.22):
Substituting into the HJB:
Dividing through by and solving for gives with , so and the optimal consumption rule is . This solution is well-defined provided , i.e., , a standard transversality condition ensuring that the agent discounts future utility sufficiently relative to wealth growth. This closed form is the natural validation target for the PINN in notebook lecture_11_04_Cake_Eating_HJB_PINN: the trained network should recover to mean relative error well below 10-3, and any larger discrepancy signals an under-trained network or a malformed loss.
7.6.0.4PINN formulation and PDE residual.¶
To solve the HJB equation (7.21) with a PINN (rather than using the closed-form above), we proceed as follows. A neural network approximates the value function. Its derivative is computed by automatic differentiation up to floating-point precision, so no finite differences are needed. From this derivative, we reconstruct the optimal consumption via the FOC (7.22):
Substituting , , and into the HJB (7.21) and moving everything to one side defines the PDE residual. In practice both the FOC inversion and the residual evaluation use a positivity-guarded derivative rather than the raw , so that consumption is well-defined even where the network’s raw derivative is negative during early training (see also the listing below):
Once training has converged with on the support, to high precision (the exponential tail decays rapidly), so the safeguarded residual is asymptotically equivalent to the original HJB residual; using throughout keeps the FOC inversion and the HJB residual mutually consistent during training, when may transiently be small or negative. If the network has perfectly learned the true value function, for all . The PINN loss is the mean squared residual over a set of collocation points sampled in the interior of the domain:
The DGM (Deep Galerkin Method) architecture of Sirignano & Spiliopoulos (2018), which provides LSTM-style gating and skip connections from the input to every hidden layer, may be used in place of the plain MLP below to improve expressivity for this type of PDE problem; the listing keeps a plain MLP for clarity. In low dimension the trial-solution MLP of notebook lecture_11_04_Cake_Eating_HJB_PINN typically outperforms a soft-BC DGM, because the boundary loss no longer competes with the interior residual; DGM becomes worthwhile primarily in higher dimensions or for PDEs with sharp internal features.
def pde_residual(model, a, gamma, rho, r):
a.requires_grad_(True)
V = model(a)
V_a = torch.autograd.grad(V.sum(), a, create_graph=True)[0]
safe_Va = F.softplus(V_a) + 1e-6 # positivity guard; +1e-6 avoids division by zero in safe_Va.pow(-1/gamma)
c = safe_Va.pow(-1.0 / gamma) # FOC
u_c = c.pow(1 - gamma) / (1 - gamma)
R = rho * V - (u_c + safe_Va * (r * a - c))
return RPINN residual for the HJB equation (PyTorch).
7.7Continuous-Time Heterogeneous Agent Models¶
Many frontier models in macroeconomics feature a continuum of agents who face idiosyncratic risk and interact through equilibrium prices. Chapter Chapter 6 studied the discrete-time version with Young’s histogram method inside a DEQN. In continuous time the same economic question becomes a coupled PDE system: a Hamilton--Jacobi--Bellman equation for individual optimization and a Kolmogorov forward (Fokker--Planck) equation for the stationary cross-sectional density, closed by a market-clearing condition that pins down prices. This is the canonical example of a PINN applied to a system of equilibrium PDEs, in contrast to the single HJB of the cake-eating problem (Section 7.6) and the single Black--Scholes PDE (Section 7.8): a PINN parameterizes the value function and the density by two networks , and minimizes a four-term loss -- the HJB residual, the KFE residual, the no-flux boundary residual at the borrowing constraint, and a mass-normalization residual -- with the loss-balancing and boundary-layer issues familiar from the rest of this chapter.
The full development -- the stochastic-calculus background, the formal HJB and KFE derivations, the Huggett and Aiyagari equilibria, the PINN solver for the stationary coupled system, the master equation that handles aggregate shocks, and the EMINN method -- is the subject of Chapter Chapter 8: see Section 8.5 and Section 8.6 for the stationary problem and Section 8.7--Section 8.8 for the aggregate-shock case. Following Achdou et al. (2022) for the model setup (whose own numerical solution uses finite differences), that treatment replaces the traditional fixed-point iteration over with joint training of all components.
7.8Application: Black--Scholes PDE¶
The Black--Scholes PDE has a closed-form solution, so a PINN run on it is not motivated by the absence of an analytical answer. The pedagogical purpose is exactly the opposite: it is a known-answer benchmark. We verify that the same PINN recipe (smooth activations, hard or soft BCs, autodiff for and , Adam-then-L-BFGS) reproduces a textbook formula on a clean domain before applying it to PDEs without closed forms (American options, jump diffusions, multi-asset pricing, HJBs with multiple state variables). If the network cannot recover Black--Scholes to plotting accuracy, no further trust should be placed in its output on harder problems.
The Black--Scholes PDE for a European call option with strike , maturity , risk-free rate , and volatility is the canonical option-pricing benchmark of Black & Scholes (1973):
with terminal condition and boundary conditions , .
The PINN approach approximates and computes the partial derivatives , , and via automatic differentiation. The total PINN loss for the Black--Scholes problem has four terms:
The loss has four terms (PDE residual, terminal condition, lower BC, upper BC) and three relative penalty weights ; the PDE residual coefficient is normalized to one. These weights must be tuned or adaptively balanced via ReLoBRaLo from Chapter Chapter 4. As a practical diagnostic of what goes wrong if the weights are mis-set: underweighting produces a smooth surface that mis-prices the payoff at maturity (the network ignores the kink at ); overweighting pins the network at but the interior PDE residual then fails to balance the term, producing visible drift in the early-time slice. In notebook lecture_11_05_Black_Scholes_PINN, the benchmark parameters are , , , , and , for which the analytical at-the-money call value is roughly 4.8. A longer teaching/production run reports a max absolute error around 0.13 and a mean absolute error around 0.04 against the analytical Black--Scholes formula (the checked-in smoke notebook prints larger errors); at the ATM value scale this is roughly a peak and average relative error. Accuracy is therefore a diagnostic to check after training, not a guaranteed property of the architecture. The choice of is natural here: it is (so is well-defined everywhere), and its bounded range provides a stable starting point for learning the option price surface.
7.9From PINNs to Operator Learning: One Network, Many Problems¶
This section is script-only outlook material; it has no companion slide and no notebook. It can be skipped on a first read without loss of continuity, and is intended for readers preparing to scale a PINN-based pipeline across many parameter configurations.
A PINN learns one solution to one PDE. Each new boundary condition, parameter set, or coefficient field forces a fresh training run. In economic and financial applications this is often exactly the bottleneck: we want option prices for many strike--maturity pairs, value functions for many discount factors, or HJB solutions across an entire parameter sweep. Operator learning flips the question: instead of learning a function that solves the PDE for a single instance, one learns the solution operator
i.e. a map between two function spaces.
Two mature architectures dominate the literature.
7.9.0.1DeepONet Lu et al., 2021.¶
Inspired by the universal-approximation theorem for nonlinear operators, DeepONet uses two sub-networks: a branch net encodes the input field at sensor locations into a latent vector, and a trunk net encodes the query point at which the output is requested; their inner product is the predicted operator output. The architecture is generic and trains entirely on input--output pairs of an offline solver.
7.9.0.2Fourier Neural Operator (FNO) Li et al., 2021.¶
FNO parameterizes a kernel integral operator by truncating it in Fourier space and applying a learned linear transformation to the low-frequency modes per layer. This captures global interactions cheaply ( via FFT) and exhibits resolution invariance: a network trained on one grid can be evaluated on a finer grid at test time.
Figure 7.7:Operator learning generalizes PINNs by amortising over an entire parametric family of PDEs. For economic applications such as option-price surfaces over , value functions across a parameter range, or HJB sweeps for sensitivity analysis (Chapter Chapter 9), training the operator once gives instant predictions at test time.
Figure Figure 7.7 summarizes this progression from one-instance PINNs to operator-learning architectures. In the rest of this script, we mostly stay with PINNs because the focus is on solving one model carefully; we revisit operator learning briefly in Chapter Chapter 12 and point readers who want to amortise across an entire parametric family of PDEs to Lu et al. (2021) Li et al. (2021).
7.10Further Reading¶
Raissi et al. (2019), the foundational PINN paper.
Sirignano & Spiliopoulos (2018), the Deep Galerkin Method, the original deep-PDE solver in finance.
E et al. (2017) Han et al. (2018), deep BSDE methods, the SDE counterpart.
Wang et al. (2021) Bischof & Kraus (2025), adaptive loss balancing for PINNs.
Lu et al. (2021), the DeepXDE software ecosystem.
7.11Exercises¶
Worked solutions and guidance for these exercises appear in Appendix Appendix F.
Automatic differentiation is the algorithmic backbone of every deep-learning framework discussed in this script; Baydin et al. (2018) survey forward- and reverse-mode AD, the dual-number and tape-based implementations, and the practical trade-offs that determine why reverse mode is the standard for neural-network training (one backward pass costs roughly the same as one forward pass, irrespective of the parameter count).
- Sirignano, J., & Spiliopoulos, K. (2018). DGM: A Deep Learning Algorithm for Solving Partial Differential Equations. Journal of Computational Physics, 375, 1339–1364.
- Raissi, M., Perdikaris, P., & Karniadakis, G. E. (2019). Physics-informed neural networks: A deep learning framework for solving forward and inverse problems involving nonlinear partial differential equations. Journal of Computational Physics, 378, 686–707.
- Barnett, M., Brock, W., & Hansen, L. P. (2020). Pricing uncertainty induced by climate change. The Review of Financial Studies, 33(3), 1024–1066.
- Duarte, V., Duarte, D., & Silva, D. (2024). Machine learning for continuous-time finance. Review of Financial Studies, 37(11), 3217–3271. 10.1093/rfs/hhae046
- Gopalakrishna, G. (2024). ALIENs and Continuous Time Economies. Available at SSRN.
- Wang, S., Teng, Y., & Perdikaris, P. (2021). Understanding and Mitigating Gradient Flow Pathologies in Physics-Informed Neural Networks. SIAM Journal on Scientific Computing, 43(5), A3055–A3081. 10.1137/20M1318043
- Bischof, R., & Kraus, M. A. (2025). Multi-Objective Loss Balancing for Physics-Informed Deep Learning. Computer Methods in Applied Mechanics and Engineering, 439, 117914. 10.1016/j.cma.2025.117914
- Sobol’, I. M. (1967). On the distribution of points in a cube and the approximate evaluation of integrals. USSR Computational Mathematics and Mathematical Physics, 7(4), 86–112.
- McKay, M. D., Beckman, R. J., & Conover, W. J. (1979). A Comparison of Three Methods for Selecting Values of Input Variables in the Analysis of Output from a Computer Code. Technometrics, 21(2), 239–245.
- Niederreiter, H. (1992). Random Number Generation and Quasi-Monte Carlo Methods (Vol. 63). SIAM.
- Owen, A. B. (1995). Randomly Permuted (t,m,s)-Nets and (t,s)-Sequences. Monte Carlo and Quasi-Monte Carlo Methods in Scientific Computing, 299–317.
- Lu, L., Meng, X., Mao, Z., & Karniadakis, G. E. (2021). DeepXDE: A Deep Learning Library for Solving Differential Equations. SIAM Review, 63(1), 208–228.
- Hochreiter, S., & Schmidhuber, J. (1997). Long short-term memory. Neural Computation, 9(8), 1735–1780.
- Srivastava, R. K., Greff, K., & Schmidhuber, J. (2015). Training Very Deep Networks. Advances in Neural Information Processing Systems (NeurIPS), 2377–2385.
- E, W., Han, J., & Jentzen, A. (2017). Deep Learning-Based Numerical Methods for High-Dimensional Parabolic Partial Differential Equations and Backward Stochastic Differential Equations. Communications in Mathematics and Statistics, 5(4), 349–380.