Residual norms: an H⁻¹ PINN loss
PINN h_minus_1_residual_loss.py
A PINN trained on the mean square of the residual clears the fine wiggles of its error at once and then crawls along the smooth error, which is most of what the solution error is. Measuring the same residual in a weaker norm, \(H^{-1}\), changes which errors the optimiser sees. One line changes.

The exact solution (left) and the two networks over 2000 Adam steps: trained on r.mse (middle) and on the
\(H^{-1}\) loss (right).
The problem
Poisson's equation on the unit square, \(-\Delta u=f\), with the exact solution of the SV-PINN paper,
\(u=\sin\pi x\sin\pi y\,[\sin(a(x+y))+\sin2\pi x+\cos3\pi y]\), \(a=10\). For a second-order operator an error mode of
frequency \(k\) enters r.mse with weight \(\sim|k|^4\). The dual norm
weights it by \(1/(1+\lambda_k)\) (SV-PINNs, Marcondes 2026, arXiv:2605.03542; the Deep Fourier Residual method, Taylor et al. 2022, arXiv:2210.14129).
The jNO code
The same network, optimiser and step budget for both losses; the residual is \(r=-\Delta u-f\):
def train(loss):
"""Train a fresh network on ``loss(residual)``; return the relative L2 error against the exact solution."""
net = jno.nn(foundax.mlp(2, 1, hidden_dims=128, num_layers=4, key=jax.random.PRNGKey(0)))
net.optimizer(optax.adam(optax.exponential_decay(1e-3, 100, 0.9))) # the SV-PINN paper's schedule
u = (net(x, y) * bubble).scalar.bind(x=x, y=y) # hard u = 0 on the boundary
r = -(u.xx + u.yy) - f # the strong residual
crux = jno.core([loss(r)], domain=d)
crux.solve(STEPS)
u_h, u_ref = (np.asarray(v).reshape(-1) for v in crux.eval([u, u_exact]))
return float(np.linalg.norm(u_h - u_ref) / np.linalg.norm(u_ref))
err_l2 = train(lambda r: r.mse) # the usual loss
err_h1 = train(lambda r: r.norm("H-1") ** 2) # the same residual, measured in H^-1
print(f"r.mse rel-L2 = {err_l2:.3e}")
print(f"r.norm('H-1')**2 rel-L2 = {err_h1:.3e}")
assert err_h1 < 0.5 * err_l2, (err_l2, err_h1)
loss is lambda r: r.mse or lambda r: r.norm("H-1") ** 2. .norm(space) takes "l2", "L2", "L1", "Linf",
"H1", "H-1" or "H^s", with bc="dirichlet" or "neumann", and picks its backend from the domain: sine or
cosine transforms on a structured lattice, P1 mass and stiffness on a simplex mesh, a Green's function on a point
cloud.
Result
A 4 × 128 tanh MLP, 2000 Adam steps, on a \(33\times33\) lattice:
| loss | rel. \(L^2\) error |
|---|---|
r.mse |
9.7e-1 |
r.norm("H-1") ** 2 |
1.1e-1 |
This is seed 0, the good case. Over three seeds and 3000 steps the median errors were 0.94 and 0.39: the plain loss stayed on its plateau in every run, the \(H^{-1}\) loss left it in one of three and partly in the others.
Full script
The whole script, as it runs in the tests
"""The residual measured in H^-1: a better-conditioned PINN loss with one changed line.
Poisson -Δu = f on the unit square with the exact solution of the SV-PINN paper's experiment 2 (Marcondes 2026,
arXiv:2605.03542): the same network, optimiser and step budget are trained on ``r.mse`` and on ``r.norm("H-1")**2``.
"""
import foundax
import jax
import optax
import jno
jax.config.update("jax_enable_x64", True)
run = jno.setup(__file__)
π, sin, cos = jno.np.pi, jno.np.sin, jno.np.cos
a, STEPS = 10.0, 2000
d = jno.shape.rect(0, 0, 1, 1).structured(n=(32, 32)).domain() # a lattice: the norm takes its sine-transform backend
x, y, _ = d.variable("interior", split=True)
bubble = x * (1 - x) * y * (1 - y)
u_exact = sin(π * x) * sin(π * y) * (sin(a * (x + y)) + sin(2 * π * x) + cos(3 * π * y))
ue = u_exact.scalar.bind(x=x, y=y)
f = -(ue.xx + ue.yy)
def train(loss):
"""Train a fresh network on ``loss(residual)``; return the relative L2 error against the exact solution."""
net = jno.nn(foundax.mlp(2, 1, hidden_dims=128, num_layers=4, key=jax.random.PRNGKey(0)))
net.optimizer(optax.adam(optax.exponential_decay(1e-3, 100, 0.9))) # the SV-PINN paper's schedule
u = (net(x, y) * bubble).scalar.bind(x=x, y=y) # hard u = 0 on the boundary
r = -(u.xx + u.yy) - f # the strong residual
crux = jno.core([loss(r)], domain=d)
crux.solve(STEPS)
u_h, u_ref = (np.asarray(v).reshape(-1) for v in crux.eval([u, u_exact]))
return float(np.linalg.norm(u_h - u_ref) / np.linalg.norm(u_ref))
err_l2 = train(lambda r: r.mse) # the usual loss
err_h1 = train(lambda r: r.norm("H-1") ** 2) # the same residual, measured in H^-1
print(f"r.mse rel-L2 = {err_l2:.3e}")
print(f"r.norm('H-1')**2 rel-L2 = {err_h1:.3e}")
assert err_h1 < 0.5 * err_l2, (err_l2, err_h1)