Type at least 2 letters. Enter opens the first result, Esc closes.

    ML for Science · Lesson 4 · Differentiable simulation

    Inverse problems, regularization and seismic imaging

    Advanced 100 min 5 interactive figures 5 videos Colab notebook

    Before this lesson: linear algebra 08 (SVD and pseudoinverse), linear algebra 12 (least squares), linear algebra 13 (conditioning) and lesson 03 (the adjoint method). Helpful: optimization 10 (Gauss–Newton) and the probability track (Bayes' rule with Gaussians). Time: about 100 minutes, plus the notebook.


    Why this matters #

    • Seismology. Earthquake location, travel-time tomography and full-waveform inversion (FWI) are inverse problems. FWI images the Earth's interior, from oil and gas reservoirs to the whole mantle, by fitting complete seismograms.
    • Weather and climate. Data assimilation (3D-Var and 4D-Var, lesson 06) is a regularized inverse problem: find the atmospheric state from sparse observations, with a forecast as the prior.
    • Imaging. Medical CT and MRI, deblurring of images and telescope data, and many more.
    • Machine learning. Ridge regression is Tikhonov regularization. Gaussian-process regression (lesson 07) is the same Bayesian computation in function space. Learned regularizers, unrolled networks and diffusion-model priors are active research on inverse problems.

    1. Predict first #

    2. The picture #

    Forward and inverse problems #

    A forward map FF sends a model mm (what we want to know) to data dd (what we can measure): d=F(m)+ed = F(m) + e, with noise ee. When FF is linear we write F(m)=GmF(m) = Gm with a matrix GG.

    problem model mm data dd forward map
    earthquake location hypocentre (x,y,z)(x, y, z) and origin time t0t_0 arrival times at stations ti=t0+distancei/vt_i = t_0 + \text{distance}_i / v (nonlinear)
    travel-time tomography slowness 1/c1/c in each cell travel times of rays GijG_{ij} = length of ray ii in cell jj (linear)
    full-waveform inversion velocity c(x)c(x) everywhere seismograms solve the wave equation (nonlinear)
    deblurring sharp signal blurred, noisy signal convolution with a blur (linear)

    Hadamard's conditions. A problem is well-posed if (1) a solution exists, (2) it is unique, and (3) it depends continuously on the data (stability). A problem that fails one of them is ill-posed. Inverse problems usually fail (3), often (2), and with noise also (1): noisy data are not exactly F(m)F(m) for any mm. After discretization the solution always depends continuously on dd, but the dependence can be extremely sensitive: the matrix is ill-conditioned (linear algebra 13).

    Why undoing a blur fails #

    A blur averages neighbouring values, so it damps fine details (high frequencies) strongly and broad features (low frequencies) weakly. In the SVD G=UΣV⊤G = U\Sigma V^\top (linear algebra 08), the right singular vectors viv_i are patterns of increasing frequency, and the singular values σi\sigma_i fall quickly. The noise has the same size in every direction uiu_i. The naive solution divides each data component by σi\sigma_i:

    mnaive=∑iui⊤dσi vi.m_\text{naive} = \sum_i \frac{u_i^\top d}{\sigma_i}\,v_i .

    Where σi\sigma_i is tiny, the noise part ui⊤eu_i^\top e is divided by a tiny number and dominates. Regularization keeps the components with large σi\sigma_i and damps the rest.

    Interactive figure: loading…

    Move the regularization weight α\alpha and the noise level, and switch the method. Upper chart: the true model (blue), the blurred noisy data (aqua dots) and the reconstruction (orange). Lower chart, on a log scale (the Picard plot): the singular values σi\sigma_i (dark line), the data coefficients ∣ui⊤d∣|u_i^\top d| (aqua), the naive coefficients ∣ui⊤d∣/σi|u_i^\top d|/\sigma_i (magenta) and the filter factors fif_i (orange). Notice that ∣ui⊤d∣|u_i^\top d| stops falling at the noise level, and from there the naive coefficients grow. With "naive", the reconstruction leaves the chart.

    Quick check

    GG has σi=10−6\sigma_i = 10^{-6}, and the data have noise ui⊤e=10−3u_i^\top e = 10^{-3} in the direction uiu_i. What error does this noise cause in the naive solution, along viv_i?

    3. Definitions and main results #

    Linear inverse problems and the SVD #

    Let G∈Rnd×nmG \in \R^{n_d\times n_m} have the SVD G=∑iσiuivi⊤G = \sum_i \sigma_i u_iv_i^\top with σ1≥σ2≥⋯>0\sigma_1 \ge \sigma_2 \ge \dots > 0 (for the nonzero ones). The minimum-norm least-squares solution (the pseudoinverse solution, linear algebra 08 and 12) is

    m†=G+d=∑σi>0ui⊤dσi vi.m^\dagger = G^+ d = \sum_{\sigma_i > 0} \frac{u_i^\top d}{\sigma_i}\,v_i .

    Noise amplification. Let d=Gmtrue+ed = Gm_\text{true} + e with noise e∼N(0,σ2I)e \sim \mathcal N(0, \sigma^2 I). Here σ\sigma (without index) is the noise level. Then

    m†=∑i(vi⊤mtrue+ui⊤eσi)vi.m^\dagger = \sum_i \Big(v_i^\top m_\text{true} + \frac{u_i^\top e}{\sigma_i}\Big)v_i .

    Because the uiu_i are orthonormal, each ui⊤eu_i^\top e is again N(0,σ2)\mathcal N(0, \sigma^2). So the error along viv_i has standard deviation σ/σi\sigma/\sigma_i. The condition number κ=σ1/σmin\kappa = \sigma_1/\sigma_\text{min} bounds how much a relative error in dd can grow in mm.

    The discrete Picard condition (Hansen 1990). The naive coefficients ui⊤d/σiu_i^\top d/\sigma_i stay bounded only if the exact data coefficients ∣ui⊤dexact∣|u_i^\top d_\text{exact}| decay faster than σi\sigma_i, on average. Real data contain noise, and ∣ui⊤e∣≈σ|u_i^\top e| \approx \sigma for every ii. So in the Picard plot, ∣ui⊤d∣|u_i^\top d| follows the decay of σi\sigma_i and then levels off at the noise level. Every component after that point is mostly noise, and dividing it by σi\sigma_i makes it explode.

    Regularization: truncated SVD and Tikhonov #

    Truncated SVD (TSVD) keeps the first kk components: mk=∑i≤k(ui⊤d/σi) vim_k = \sum_{i\le k}(u_i^\top d/\sigma_i)\,v_i.

    Tikhonov regularization (Tikhonov 1963) adds a penalty on the size of the model:

    mα=arg⁡min⁡m  ∥Gm−d∥2+α2∥m∥2=(G⊤G+α2I)−1G⊤d.\begin{aligned} m_\alpha &= \arg\min_m\; \|Gm - d\|^2 + \alpha^2\|m\|^2 \\ &= (G^\top G + \alpha^2 I)^{-1}G^\top d . \end{aligned}

    Theorem 1 (filter factors). In the SVD basis,

    mα=∑ifi ui⊤dσi vi,fi=σi2σi2+α2.\begin{gathered} m_\alpha = \sum_i f_i\,\frac{u_i^\top d}{\sigma_i}\,v_i, \\ f_i = \frac{\sigma_i^2}{\sigma_i^2 + \alpha^2}. \end{gathered}

    Proof.

    1. The objective is a convex quadratic. Its gradient 2G⊤(Gm−d)+2α2m2G^\top(Gm - d) + 2\alpha^2 m is zero at the minimum, so (G⊤G+α2I)mα=G⊤d(G^\top G + \alpha^2 I)m_\alpha = G^\top d. The matrix is positive definite for α>0\alpha > 0, so the solution is unique.
    2. With G=UΣV⊤G = U\Sigma V^\top (full VV, orthogonal): G⊤G+α2I=V(Σ⊤Σ+α2I)V⊤G^\top G + \alpha^2 I = V(\Sigma^\top\Sigma + \alpha^2 I)V^\top and G⊤d=VΣ⊤U⊤dG^\top d = V\Sigma^\top U^\top d.
    3. So mα=V(Σ⊤Σ+α2I)−1Σ⊤U⊤dm_\alpha = V(\Sigma^\top\Sigma + \alpha^2 I)^{-1}\Sigma^\top U^\top d. The diagonal matrix in the middle has entries σi/(σi2+α2)=fi/σi\sigma_i/(\sigma_i^2 + \alpha^2) = f_i/\sigma_i. ■\blacksquare

    What the filter factors do.

    • σi≫α\sigma_i \gg \alpha: fi≈1f_i \approx 1, the component is kept.
    • σi≪α\sigma_i \ll \alpha: fi≈σi2/α2f_i \approx \sigma_i^2/\alpha^2, the component is removed.
    • σi=α\sigma_i = \alpha: fi=12f_i = \tfrac12. So α\alpha is the singular value where the filter switches.
    • The noise gain fi/σi=σi/(σi2+α2)f_i/\sigma_i = \sigma_i/(\sigma_i^2 + \alpha^2) is at most 1/(2α)1/(2\alpha) (its maximum, at σi=α\sigma_i = \alpha). So noise can be amplified by at most 1/(2α)1/(2\alpha), instead of 1/σmin1/\sigma_\text{min}.

    TSVD uses fi∈{0,1}f_i \in \{0, 1\}; Tikhonov switches smoothly. Larger α\alpha means less noise in mαm_\alpha (less variance) but more lost detail (more bias).

    Quick check

    Tikhonov regularization with weight α\alpha. A component has singular value σi=α\sigma_i = \alpha. What filter factor does it get?

    Choosing α\alpha.

    • Discrepancy principle (Morozov 1966). A good model should fit the data only as well as the noise allows: choose α\alpha so that ∥Gmα−d∥≈∥e∥≈nd σ\|Gm_\alpha - d\| \approx \|e\| \approx \sqrt{n_d}\,\sigma. It needs the noise level, and it tends to choose an α\alpha slightly too large (slightly too smooth).
    • L-curve (Hansen 1992). Plot log⁡∥mα∥\log\|m_\alpha\| against log⁡∥Gmα−d∥\log\|Gm_\alpha - d\| for many α\alpha. The curve has the shape of an L. On the vertical part, a smaller α\alpha fits a little more noise and the model norm explodes; on the horizontal part, a larger α\alpha removes signal and the residual grows. Choose the corner. It does not need the noise level.
    • Generalized cross-validation (GCV) is a third common choice; it predicts each datum from the others.
    Interactive figure: loading…

    Move α\alpha along the L-curve, and change the noise level. Upper chart: the L-curve (∥Gmα−d∥,∥mα∥)(\|Gm_\alpha - d\|, \|m_\alpha\|) on log–log axes, with the current α\alpha as a dot. Lower chart: the true error ∥mα−mtrue∥\|m_\alpha - m_\text{true}\| (magenta) against α\alpha. The vertical marks show the corner of the L (largest curvature, dark), the discrepancy-principle choice (aqua) and the smallest error (blue). Notice that both rules land near the flat valley of the error curve without knowing mtruem_\text{true}; the discrepancy choice is usually closer to the best α\alpha, and the corner can miss it by a factor of several.

    General-form Tikhonov and sparsity

    Instead of α2∥m∥2\alpha^2\|m\|^2 one often penalizes α2∥Lm∥2\alpha^2\|Lm\|^2 with a derivative matrix LL, so smooth models are preferred, not small ones. The solution uses the generalized SVD of (G,L)(G, L). With an ℓ1\ell_1 penalty, α∥Lm∥1\alpha\|Lm\|_1 (total variation when LL is a first difference), sharp edges survive. The problem stays convex but is no longer quadratic; proximal methods solve it (optimization 09).

    The Bayesian view: Tikhonov is MAP #

    Model the noise and the prior as Gaussians: e∼N(0,σ2I)e \sim \mathcal N(0, \sigma^2 I) and m∼N(0,τ2I)m \sim \mathcal N(0, \tau^2 I). By Bayes' rule the posterior density is

    p(m∣d)∝p(d∣m) p(m)∝exp⁡ ⁣(−∥Gm−d∥22σ2−∥m∥22τ2).\begin{aligned} p(m \mid d) &\propto p(d \mid m)\,p(m) \\ &\propto \exp\!\Big(-\frac{\|Gm - d\|^2}{2\sigma^2} - \frac{\|m\|^2}{2\tau^2}\Big). \end{aligned}

    Theorem 2 (Tikhonov = MAP). The maximum a posteriori (MAP) estimate is the Tikhonov solution with α2=σ2/τ2\alpha^2 = \sigma^2/\tau^2. Equivalently, Tikhonov with weight α\alpha is MAP for the prior m∼N(0,α−2σ2I)m \sim \mathcal N(0, \alpha^{-2}\sigma^2 I). The posterior is Gaussian with mean mαm_\alpha and covariance

    Σpost=(G⊤Gσ2+Iτ2)−1=σ2 (G⊤G+α2I)−1.\begin{aligned} \Sigma_\text{post} &= \Big(\frac{G^\top G}{\sigma^2} + \frac{I}{\tau^2}\Big)^{-1} \\ &= \sigma^2\,(G^\top G + \alpha^2 I)^{-1}. \end{aligned}

    Proof.

    1. Maximizing p(m∣d)p(m\mid d) is minimizing −2σ2log⁡p(m∣d)=∥Gm−d∥2+(σ2/τ2)∥m∥2+const-2\sigma^2\log p(m\mid d) = \|Gm - d\|^2 + (\sigma^2/\tau^2)\|m\|^2 + \text{const}: the Tikhonov objective with α2=σ2/τ2\alpha^2 = \sigma^2/\tau^2.
    2. The exponent is a quadratic in mm with Hessian G⊤G/σ2+I/τ2G^\top G/\sigma^2 + I/\tau^2. A density of the form exp⁡(−12(m−μ)⊤P(m−μ))\exp(-\tfrac12(m - \mu)^\top P(m - \mu)) is Gaussian with covariance P−1P^{-1}; its mean is the minimizer, mαm_\alpha. Multiply PP by σ2\sigma^2 and use σ2/τ2=α2\sigma^2/\tau^2 = \alpha^2 for the second form. ■\blacksquare

    In the SVD basis the posterior variance along viv_i is σ2/(σi2+α2)\sigma^2/(\sigma_i^2 + \alpha^2). For large σi\sigma_i it is about σ2/σi2\sigma^2/\sigma_i^2: the data determine this direction. For small σi\sigma_i it is about σ2/α2=τ2\sigma^2/\alpha^2 = \tau^2, the prior variance: the data say nothing about this direction, and we keep the prior.

    General Gaussian prior and noise. With m∼N(mb,B)m \sim \mathcal N(m_b, B) and e∼N(0,R)e \sim \mathcal N(0, R), MAP minimizes

    J(m)=12(m−mb)⊤B−1(m−mb)+12(Gm−d)⊤R−1(Gm−d).\begin{aligned} J(m) = {}&\tfrac12(m - m_b)^\top B^{-1}(m - m_b) \\ &+ \tfrac12(Gm - d)^\top R^{-1}(Gm - d). \end{aligned}

    This is exactly the 3D-Var cost of data assimilation (lesson 06), with background state mbm_b and observation operator GG. Its posterior mean, written with kernel matrices, is the posterior mean of Gaussian-process regression (lesson 07).

    Quick check

    The data noise is N(0,σ2I)\mathcal N(0, \sigma^2 I). For which prior on mm is the Tikhonov solution arg⁡min⁡∥Gm−d∥2+α2∥m∥2\arg\min \|Gm - d\|^2 + \alpha^2\|m\|^2 the MAP estimate?

    Nonlinear problems: Gauss–Newton and earthquake location #

    For a nonlinear forward map we minimize the misfit J(m)=12∥F(m)−d∥2J(m) = \tfrac12\|F(m) - d\|^2. Let r=F(m)−dr = F(m) - d be the residual and JFJ_F the Jacobian of FF at mm. Gauss–Newton linearizes F(m+δ)≈F(m)+JFδF(m + \delta) \approx F(m) + J_F\delta and solves the linear least-squares problem for the step:

    (JF⊤JF) δ=−JF⊤r,m←m+δ.(J_F^\top J_F)\,\delta = -J_F^\top r, \qquad m \leftarrow m + \delta .

    It uses JF⊤JFJ_F^\top J_F in place of the Hessian of JJ, which drops the second derivatives of FF (optimization 10). Adding α2I\alpha^2 I to JF⊤JFJ_F^\top J_F gives the Levenberg–Marquardt method, a regularized step.

    Earthquake location (Geiger's method, 1912). Stations at known positions sis_i record the arrival time tit_i of the first wave. In a medium with constant speed vv,

    Fi(m)=t0+∥si−x∥v,m=(x,t0),F_i(m) = t_0 + \frac{\|s_i - x\|}{v}, \qquad m = (x, t_0),

    where xx is the hypocentre and t0t_0 the origin time (mm has 4 entries in 3D; the figure uses 2D and 3 entries). Row ii of the Jacobian is ((x−si)⊤/(v∥x−si∥), 1)\big((x - s_i)^\top/(v\|x - s_i\|),\ 1\big): a unit vector from the station to the source, divided by vv, and a 1 for t0t_0.

    Station geometry. If all stations lie on one side, the unit vectors are almost parallel, the rows of JFJ_F are almost dependent, and JF⊤JFJ_F^\top J_F is ill-conditioned. The linearized posterior covariance σt2(JF⊤JF)−1\sigma_t^2(J_F^\top J_F)^{-1} (for timing noise σt\sigma_t) is then a long ellipse: the source can move along one direction (often away from the stations, with a later or earlier t0t_0) almost without changing the arrival times. Depth and origin time trade off in the same way when all stations are far away.

    Interactive figure: loading…

    Drag the stations (triangles) and the starting guess (orange), then press Gauss–Newton step. The shading is the misfit (stronger colour is larger), minimized over the origin time; the blue star is the true epicentre. The dashed orange ellipse is the linearized 95% uncertainty region at the current estimate. Try "one side" and "in a line": the misfit valley becomes long, the ellipse stretches, and with stations in a line there are two mirror minima.

    The adjoint-state method #

    Many forward maps are given by a large equation for a state uu (a wavefield, a temperature):

    A(m) u=s,J(m)=j(u(m)),A(m)\,u = s, \qquad J(m) = j(u(m)),

    for example j(u)=12∥Pu−d∥2j(u) = \tfrac12\|Pu - d\|^2, where PP samples the state at the receivers. We need ∇mJ\nabla_m J for millions of parameters.

    Theorem 3 (adjoint-state gradient). Let A(m)A(m) be invertible and differentiable in mm. Let the adjoint state λ\lambda solve

    A(m)⊤λ=−∇uj(u).A(m)^\top\lambda = -\nabla_u j(u).

    Then

    ∂J∂mk=λ⊤ ∂A(m)∂mk u\frac{\partial J}{\partial m_k} = \lambda^\top\,\frac{\partial A(m)}{\partial m_k}\,u

    for every kk.

    Proof (implicit differentiation, as in calculus 09).

    1. Differentiate A(m)u(m)=sA(m)u(m) = s with respect to mkm_k: ∂A∂mku+A∂u∂mk=0\frac{\partial A}{\partial m_k}u + A\frac{\partial u}{\partial m_k} = 0, so ∂u∂mk=−A−1∂A∂mku\frac{\partial u}{\partial m_k} = -A^{-1}\frac{\partial A}{\partial m_k}u.
    2. Chain rule: ∂J∂mk=∇uj⊤∂u∂mk=−∇uj⊤A−1∂A∂mku\frac{\partial J}{\partial m_k} = \nabla_u j^\top\frac{\partial u}{\partial m_k} = -\nabla_u j^\top A^{-1}\frac{\partial A}{\partial m_k}u.
    3. The row vector −∇uj⊤A−1-\nabla_u j^\top A^{-1} is λ⊤\lambda^\top, because λ=−A−⊤∇uj\lambda = -A^{-\top}\nabla_u j. So ∂J∂mk=λ⊤∂A∂mku\frac{\partial J}{\partial m_k} = \lambda^\top\frac{\partial A}{\partial m_k}u. ■\blacksquare

    Cost. One forward solve for uu and one adjoint solve for λ\lambda, then a cheap product for each kk. The number of solves does not depend on the number of parameters. With several sources, the cost is one forward and one adjoint solve per source.

    The same result with a Lagrangian
    1. Define L(u,λ,m)=j(u)+λ⊤(A(m)u−s)\mathcal L(u, \lambda, m) = j(u) + \lambda^\top(A(m)u - s). When u=u(m)u = u(m) solves the state equation, L=J(m)\mathcal L = J(m) for every λ\lambda.
    2. dJdmk=∂L∂u∂u∂mk+∂L∂mk\frac{dJ}{dm_k} = \frac{\partial\mathcal L}{\partial u}\frac{\partial u}{\partial m_k} + \frac{\partial\mathcal L}{\partial m_k}, with ∂L∂u=∇uj⊤+λ⊤A\frac{\partial\mathcal L}{\partial u} = \nabla_u j^\top + \lambda^\top A.
    3. Choose λ\lambda so that ∂L∂u=0\frac{\partial\mathcal L}{\partial u} = 0: this is A⊤λ=−∇ujA^\top\lambda = -\nabla_u j. The unknown ∂u/∂mk\partial u/\partial m_k then drops out.
    4. What remains is ∂L∂mk=λ⊤∂A∂mku\frac{\partial\mathcal L}{\partial m_k} = \lambda^\top\frac{\partial A}{\partial m_k}u. ■\blacksquare

    Lesson 03 is the special case where A(m)u=sA(m)u = s is the whole time-stepping scheme: the matrix is block lower triangular in time, so A⊤A^\top is block upper triangular, and solving with it runs backward in time.

    Full-waveform inversion #

    In 1D, the acoustic wave equation with squared slowness m(x)=1/c(x)2m(x) = 1/c(x)^2 and a source at xsx_s is

    m(x) utt−uxx=w(t) δ(x−xs),u=ut=0 at t=0.\begin{gathered} m(x)\,u_{tt} - u_{xx} = w(t)\,\delta(x - x_s), \\ u = u_t = 0 \text{ at } t = 0 . \end{gathered}

    A receiver at xrx_r records u(xr,t)u(x_r, t). FWI minimizes the waveform misfit

    J(m)=12∫0T(u(xr,t)−d(t))2 dt.J(m) = \tfrac12\int_0^T \big(u(x_r, t) - d(t)\big)^2\,dt .

    Theorem 4 (FWI gradient). Let λ\lambda solve the adjoint wave equation with the residual as a source at the receiver and final conditions:

    m(x) λtt−λxx=−(u(xr,t)−d(t)) δ(x−xr),λ=λt=0 at t=T.\begin{gathered} m(x)\,\lambda_{tt} - \lambda_{xx} = -\big(u(x_r, t) - d(t)\big)\,\delta(x - x_r), \\ \lambda = \lambda_t = 0 \text{ at } t = T . \end{gathered}

    Then

    ∇mJ(x)=∫0Tλ(x,t) utt(x,t) dt.\nabla_m J(x) = \int_0^T \lambda(x, t)\,u_{tt}(x, t)\,dt .

    Why this is true. This is Theorem 3 with A(m)u=m utt−uxxA(m)u = m\,u_{tt} - u_{xx}. The derivative of A(m)uA(m)u with respect to m(x)m(x) is utt(x,⋅)u_{tt}(x, \cdot), and the pairing λ⊤(… )\lambda^\top(\dots) is an integral over time. The wave operator is symmetric in space, and its transpose in time turns the initial conditions into final conditions: the adjoint equation runs backward. Because the wave equation is time-reversible, "the residual played backward from the receiver" is a wave that travels back into the model.

    Derivation with the Lagrangian
    1. L=J+∫0T ⁣ ⁣∫λ (m utt−uxx−w δxs) dx dt\mathcal L = J + \int_0^T\!\!\int \lambda\,(m\,u_{tt} - u_{xx} - w\,\delta_{x_s})\,dx\,dt.
    2. Perturb uu by δu\delta u with δu=δut=0\delta u = \delta u_t = 0 at t=0t = 0. Integrate by parts twice in tt and twice in xx (the boundary terms in xx vanish for a large domain or for matching boundary conditions): ∫ ⁣ ⁣∫λ (m δutt−δuxx)=∫ ⁣ ⁣∫(m λtt−λxx) δu+[∫m(λ δut−λt δu) dx]t=T\int\!\!\int \lambda\,(m\,\delta u_{tt} - \delta u_{xx}) = \int\!\!\int (m\,\lambda_{tt} - \lambda_{xx})\,\delta u + \big[\int m(\lambda\,\delta u_t - \lambda_t\,\delta u)\,dx\big]_{t=T}.
    3. The term from JJ is ∫(u(xr,t)−d(t)) δu(xr,t) dt=∫ ⁣ ⁣∫(u−d) δ(x−xr) δu\int (u(x_r, t) - d(t))\,\delta u(x_r, t)\,dt = \int\!\!\int (u - d)\,\delta(x - x_r)\,\delta u.
    4. Setting all terms with δu\delta u to zero gives the adjoint equation and the final conditions λ=λt=0\lambda = \lambda_t = 0 at t=Tt = T.
    5. What remains is ∂L/∂m(x)=∫0Tλ utt dt\partial\mathcal L/\partial m(x) = \int_0^T\lambda\,u_{tt}\,dt. ■\blacksquare

    We checked the discrete version of this formula (leapfrog time stepping, the discrete adjoint run backward) against finite differences of the misfit; they agree to 8 digits. The notebook repeats the check.

    What the gradient looks like. At each point xx the gradient is the zero-lag cross-correlation of the forward field's acceleration with the adjoint field. In a reflection setting (source and receiver at the surface) the residual contains the reflected waves that the starting model misses. Sent back into the model, they meet the forward field exactly at the depth of the reflector. So the first gradient is an image of the reflectors: this is the link between FWI and reverse-time migration. Also, 10710^7 unknowns need only two simulations per source (forward and adjoint).

    Interactive figure: loading…

    Press Play (or drag the time) to run the adjoint backward from TT to 0. The source and the receiver are at the surface x=0x = 0; the starting model has c=1c = 1, and the true model has a layer (shaded). Upper chart: the forward wavefield u(x,t)u(x, t) of the starting model (blue) and the adjoint field λ(x,t)\lambda(x, t) (violet) at the current time. Middle chart: the recorded trace d(t)d(t) (aqua), the predicted trace (orange, dashed) and the residual (magenta). Lower chart: the gradient ∫tTλ utt dt\int_t^T \lambda\,u_{tt}\,dt accumulated so far (magenta). Notice that it grows only where λ\lambda and uu meet, at the edges of the layer, and that the image of the top of the layer changes sign when you switch to a slower layer.

    Quick check

    FWI with one seismic source and 10710^7 unknown velocity values. How many wave simulations does one gradient of the misfit need with the adjoint-state method?

    Cycle skipping #

    FWI minimizes JJ with gradient methods, so it finds a local minimum. Consider one arrival: the predicted wavelet is the observed wavelet shifted in time by Δ\Delta. For a wavelet of period PP, the misfit J(Δ)J(\Delta) has local minima near Δ=±P,±2P,…\Delta = \pm P, \pm 2P, \dots, where the predicted wavelet matches the wrong cycle of the observed one. If the starting model predicts the arrival wrong by more than about half a period, gradient descent moves toward the wrong cycle: this is cycle skipping. For the Ricker wavelet with peak frequency ff we use here, the basin of the correct minimum ends at ∣Δ∣≈0.43/f|\Delta| \approx 0.43/f, a little less than half of the period 1/f1/f.

    Remedies.

    • Low frequencies first (Bunks et al. 1995). The period of a low-frequency wavelet is long, so the same time error is a small fraction of a period. Invert low-pass filtered data first, then add higher frequencies step by step.
    • A good starting model, for example from travel-time tomography.
    • Other misfits that compare shapes instead of point values, for example optimal-transport distances (Engquist and Froese 2014) or envelopes.
    Interactive figure: loading…

    Drag the starting velocity and change the high frequency. The curves are the misfit against the model velocity for a low-frequency (blue) and a high-frequency (orange) wavelet; the true velocity is 2 km/s. The dots show where gradient descent from the starting velocity ends. Notice that the high-frequency curve has local minima, and that descent finds the true velocity only when the time error is below about half a period.

    Quick check

    Why does FWI usually start with the lowest frequencies in the data?

    Machine learning and inverse problems
    • Learned regularizers. Replace α2∥m∥2\alpha^2\|m\|^2 by a penalty learned from examples of good models, for example an adversarially trained critic (Lunz, Öktem and Schönlieb 2018).
    • Unrolled optimization. Take KK iterations of a gradient or proximal method, give each iteration learnable parameters, and train the whole chain end to end (LISTA, Gregor and LeCun 2010; learned primal-dual, Adler and Öktem 2018). The forward map and its adjoint stay inside the network.
    • Generative priors. Plug-and-play methods use a denoiser as the prior step (Venkatakrishnan et al. 2013); diffusion posterior sampling uses a pretrained diffusion model as the prior and the gradient of the data misfit for guidance (Chung et al. 2023; lessons 12–13 for the diffusion side).
    • Differentiable simulators. Write the forward model in an automatic-differentiation framework, and the adjoint-state gradient comes for free (the discrete adjoint of lesson 03). This also lets a neural network inside the simulator be trained through the physics.
    • Amortized and simulation-based inference. Train a network on simulated pairs (m,d)(m, d) to output the posterior p(m∣d)p(m \mid d) for any new dd in one pass (Cranmer, Brehmer and Louppe 2020).
    • In seismology, deep networks already pick the arrival times that earthquake location uses (for example PhaseNet, Zhu and Beroza 2019).

    Answers to section 1. (1) 10310^3: the noise component 10−310^{-3} is divided by σi=10−6\sigma_i = 10^{-6}. (2) One half: fi=α2/(α2+α2)=12f_i = \alpha^2/(\alpha^2 + \alpha^2) = \tfrac12. (3) Two: one forward and one adjoint wave simulation, whatever the number of unknowns (Theorem 3).

    4. Worked example #

    (a) Regularization in two dimensions. Let v1=(1,1)/2v_1 = (1, 1)/\sqrt2 and v2=(1,−1)/2v_2 = (1, -1)/\sqrt2, and

    G=1⋅v1v1⊤+0.01⋅v2v2⊤=(0.5050.4950.4950.505).\begin{aligned} G &= 1\cdot v_1v_1^\top + 0.01\cdot v_2v_2^\top \\ &= \begin{pmatrix} 0.505 & 0.495 \\ 0.495 & 0.505 \end{pmatrix}. \end{aligned}

    GG is symmetric with eigenvalues 11 and 0.010.01, so its SVD has ui=viu_i = v_i, σ1=1\sigma_1 = 1, σ2=0.01\sigma_2 = 0.01, and κ=100\kappa = 100. Take mtrue=(1,1)m_\text{true} = (1, 1) and noise e=(0.01,−0.01)e = (0.01, -0.01).

    1. Data: Gmtrue=(1,1)Gm_\text{true} = (1, 1) (it lies along v1v_1), so d=(1.01,0.99)d = (1.01, 0.99).
    2. Coefficients: u1⊤d=(1.01+0.99)/2=2u_1^\top d = (1.01 + 0.99)/\sqrt2 = \sqrt2 and u2⊤d=(1.01−0.99)/2=0.02/2u_2^\top d = (1.01 - 0.99)/\sqrt2 = 0.02/\sqrt2.
    3. Naive solution: 21v1+0.02/20.01v2=(1,1)+(1,−1)=(2,0)\frac{\sqrt2}{1}v_1 + \frac{0.02/\sqrt2}{0.01}v_2 = (1, 1) + (1, -1) = (2, 0). A noise of size 0.0140.014 caused an error of size 2≈1.41\sqrt2 \approx 1.41: amplification 1/σ2=1001/\sigma_2 = 100.
    4. Tikhonov with α=0.1\alpha = 0.1: f1=11+0.01≈0.990f_1 = \frac{1}{1 + 0.01} \approx 0.990 and f2=0.00010.0001+0.01=1101≈0.0099f_2 = \frac{0.0001}{0.0001 + 0.01} = \frac{1}{101} \approx 0.0099.
    5. mα=0.990 (1,1)+0.0099 (1,−1)=(1.000,0.980)m_\alpha = 0.990\,(1, 1) + 0.0099\,(1, -1) = (1.000, 0.980). The error is 0.01980.0198 instead of 1.411.41.

    The regularized solution lost almost nothing along v1v_1 (bias 1%1\%) and removed almost all of the noise along v2v_2.

    (b) The adjoint-state method by hand. Let

    A(m)=(2+m1−1−12+m2),s=(10),J(m)=12∥u−d∥2,d=(0.50.5),\begin{gathered} A(m) = \begin{pmatrix} 2 + m_1 & -1 \\ -1 & 2 + m_2 \end{pmatrix}, \quad s = \begin{pmatrix} 1 \\ 0 \end{pmatrix}, \\ J(m) = \tfrac12\|u - d\|^2, \quad d = \begin{pmatrix} 0.5 \\ 0.5 \end{pmatrix}, \end{gathered}

    at m=(0,0)m = (0, 0).

    1. Forward solve: A=(2−1−12)A = \begin{pmatrix} 2 & -1 \\ -1 & 2 \end{pmatrix}, A−1=13(2112)A^{-1} = \frac13\begin{pmatrix} 2 & 1 \\ 1 & 2 \end{pmatrix}, so u=A−1s=(23,13)u = A^{-1}s = (\tfrac23, \tfrac13).
    2. Residual: ∇uj=u−d=(16,−16)\nabla_u j = u - d = (\tfrac16, -\tfrac16).
    3. Adjoint solve (AA is symmetric): λ=−A−1(16,−16)=−13(16,−16)=(−118,118)\lambda = -A^{-1}(\tfrac16, -\tfrac16) = -\tfrac13(\tfrac16, -\tfrac16) = (-\tfrac{1}{18}, \tfrac{1}{18}).
    4. Derivatives of the operator: ∂A/∂m1=e1e1⊤\partial A/\partial m_1 = e_1e_1^\top, so ∂A∂m1u=(u1,0)\frac{\partial A}{\partial m_1}u = (u_1, 0); likewise ∂A∂m2u=(0,u2)\frac{\partial A}{\partial m_2}u = (0, u_2).
    5. Gradient: ∂J/∂m1=λ1u1=−118⋅23=−127\partial J/\partial m_1 = \lambda_1u_1 = -\tfrac{1}{18}\cdot\tfrac23 = -\tfrac{1}{27} and ∂J/∂m2=λ2u2=118⋅13=154\partial J/\partial m_2 = \lambda_2u_2 = \tfrac{1}{18}\cdot\tfrac13 = \tfrac{1}{54}.

    Check: central finite differences of JJ give −0.0370370-0.0370370 and 0.01851850.0185185 ✓. Two linear solves gave both derivatives; with 10710^7 parameters it would still be two solves.

    5. In code #

    NumPy checks the deblurring numbers, the discrepancy principle and the adjoint-state example. The notebook has these cells and the exercises.

    import numpy as np
    
    # 1. A 1D blur (deconvolution) problem: d = G m + noise
    n = 64
    x = (np.arange(n) + 0.5) / n
    w = 0.03                                            # width of the Gaussian blur
    G = np.exp(-(x[:, None] - x[None, :]) ** 2 / (2 * w**2)) / (np.sqrt(2 * np.pi) * w * n)
    m_true = ((x > 0.15) & (x < 0.35)) + 0.8 * np.exp(-((x - 0.68) / 0.07) ** 2)
    sigma = 1e-3                                        # noise level
    d = G @ m_true + sigma * np.random.default_rng(0).normal(size=n)
    
    U, s, Vt = np.linalg.svd(G)
    print(f"{s[0]:.3f} {s[40]:.1e} {s[0] / s[-1]:.1e}")  # 0.996 1.0e-03 3.3e+07
    m_naive = np.linalg.solve(G, d)
    print(f"{np.linalg.norm(m_naive - m_true):.1e}")    # 5.1e+04: the naive inverse is useless
    
    # 2. Tikhonov through the filter factors f_i = s_i^2 / (s_i^2 + alpha^2)
    beta = U.T @ d                                      # coefficients u_i^T d
    def tikhonov(alpha):
        f = s**2 / (s**2 + alpha**2)
        return Vt.T @ (f * beta / s)
    
    for alpha in [1e-4, 1e-3, 1e-2, 1e-1]:
        m = tikhonov(alpha)
        print(f"{alpha:.0e} residual {np.linalg.norm(G @ m - d):.2e} error {np.linalg.norm(m - m_true):.2f}")
    # 1e-04 residual 3.09e-03 error 8.60
    # 1e-03 residual 3.64e-03 error 1.17
    # 1e-02 residual 4.91e-03 error 0.54
    # 1e-01 residual 4.99e-02 error 0.69
    
    # 3. Discrepancy principle: choose alpha with ||G m_alpha - d|| = sqrt(n) sigma (bisection in log alpha)
    lo, hi = -6.0, 0.0
    for _ in range(60):
        mid = (lo + hi) / 2
        r = np.linalg.norm(G @ tikhonov(10**mid) - d)
        lo, hi = (mid, hi) if r < np.sqrt(n) * sigma else (lo, mid)
    a_dp = 10**lo
    print(f"alpha {a_dp:.3f} error {np.linalg.norm(tikhonov(a_dp) - m_true):.2f}")   # alpha 0.025 error 0.57
    
    # 4. Adjoint-state gradient for A(m) u = s, J = |u - d|^2 / 2, checked with finite differences
    def A(m): return np.array([[2 + m[0], -1.0], [-1.0, 2 + m[1]]])
    src, dat = np.array([1.0, 0.0]), np.array([0.5, 0.5])
    def J(m): u = np.linalg.solve(A(m), src); return 0.5 * np.sum((u - dat) ** 2)
    m0 = np.zeros(2)
    u = np.linalg.solve(A(m0), src)                     # forward solve
    lam = np.linalg.solve(A(m0).T, -(u - dat))          # adjoint solve: A^T lam = -grad_u J
    grad = np.array([lam[0] * u[0], lam[1] * u[1]])     # lam^T (dA/dm_k) u, with dA/dm_k = e_k e_k^T
    fd = [(J(m0 + 1e-6 * e) - J(m0 - 1e-6 * e)) / 2e-6 for e in np.eye(2)]
    print(grad, np.round(fd, 8))                        # [-0.03703704  0.01851852] [-0.03703704  0.01851852]
    

    The residual stays near 3⋅10−33\cdot10^{-3} for small α\alpha because the model can fit almost all of the data, noise included; the target of the discrepancy principle is 64⋅10−3=8⋅10−3\sqrt{64}\cdot10^{-3} = 8\cdot10^{-3}. The smallest error in this list is at α=10−2\alpha = 10^{-2}; the discrepancy principle chooses a slightly larger α\alpha, as expected.

    6. Where it shows up #

    • Global and regional seismology. Adjoint tomography fits full seismograms of many earthquakes with the adjoint-state gradient (Tromp, Tape and Liu 2005). Global models of the mantle have been built this way from hundreds of earthquakes (for example GLAD-M15, Bozdağ et al. 2016).
    • Exploration geophysics. FWI is a standard step in building velocity models for reservoirs (review: Virieux and Operto 2009). The first gradient is closely related to reverse-time migration.
    • Earthquake catalogs. Every earthquake catalog comes from solving a location problem for each event. Relative methods such as double-difference location (Waldhauser and Ellsworth 2000) reduce the effect of an imperfect velocity model.
    • Weather and climate. 3D-Var and 4D-Var are regularized inverse problems with the forecast as the prior (lesson 06); 4D-Var uses the adjoint of the forecast model, as FWI uses the adjoint of the wave equation.
    • Machine learning. Ridge regression is Tikhonov regularization with the data matrix as GG. Weight decay is the same penalty on network weights. Learned reconstruction methods for CT and MRI combine the forward operator with trained networks.

    7. Common mistakes #

    • Inverting an ill-conditioned matrix directly. np.linalg.solve(G, d) returns an answer, but it is dominated by amplified noise. Look at the singular values and the Picard plot first.
    • Choosing α\alpha by the best fit to the data. The residual always falls as α→0\alpha \to 0; the best fit is the noisiest model. Use the discrepancy principle, the L-curve, GCV or a held-out set.
    • Mixing up α\alpha and α2\alpha^2. With the objective ∥Gm−d∥2+α2∥m∥2\|Gm - d\|^2 + \alpha^2\|m\|^2 the filter factor switches at σi=α\sigma_i = \alpha and the prior variance is σ2/α2\sigma^2/\alpha^2. Libraries often write λ∥m∥2\lambda\|m\|^2 with λ=α2\lambda = \alpha^2.
    • A wrong sign or a missing time reversal in the adjoint. The adjoint wave equation has final conditions and runs backward. Check every adjoint gradient against finite differences on a small problem before using it.
    • Starting FWI with high frequencies or a poor model. The misfit is not convex; cycle skipping gives a wrong model with a small gradient. Start from low frequencies and a smooth, travel-time-based model.
    • Reading the regularized solution as the truth. Components with small σi\sigma_i come from the prior, not from the data. Report the posterior uncertainty or the resolution.

    8. Check yourself #

    1. State Hadamard's three conditions. Which one fails for deblurring, and why does a discrete blur matrix still "work" in exact arithmetic?
      AnswerExistence, uniqueness, continuous dependence on the data. Stability fails: tiny changes in the data cause huge changes in the solution. A discrete blur matrix is usually invertible, so the solution depends continuously on dd, but the constant (the condition number, here about 3⋅1073\cdot10^7) is so large that rounding and noise dominate.
    2. Write the Tikhonov solution in the SVD basis. What is the largest possible amplification of a data error, and for which singular value does it happen?
      Answermα=∑iσiσi2+α2(ui⊤d) vim_\alpha = \sum_i \frac{\sigma_i}{\sigma_i^2 + \alpha^2}(u_i^\top d)\,v_i. The gain σ/(σ2+α2)\sigma/(\sigma^2 + \alpha^2) is largest at σ=α\sigma = \alpha (set its derivative (α2−σ2)/(σ2+α2)2(\alpha^2 - \sigma^2)/(\sigma^2 + \alpha^2)^2 to zero), where it equals 1/(2α)1/(2\alpha).
    3. The noise level is σ=0.01\sigma = 0.01 and there are nd=400n_d = 400 data. What residual norm does the discrepancy principle aim for?
      Answer∥Gmα−d∥≈nd σ=20⋅0.01=0.2\|Gm_\alpha - d\| \approx \sqrt{n_d}\,\sigma = 20 \cdot 0.01 = 0.2, the expected size of the noise vector.
    4. Give the posterior covariance of the Tikhonov problem with noise N(0,σ2I)\mathcal N(0, \sigma^2 I), and its variance along viv_i. What happens for σi→0\sigma_i \to 0?
      AnswerΣpost=σ2(G⊤G+α2I)−1\Sigma_\text{post} = \sigma^2(G^\top G + \alpha^2 I)^{-1}; along viv_i the variance is σ2/(σi2+α2)\sigma^2/(\sigma_i^2 + \alpha^2). For σi→0\sigma_i \to 0 it tends to σ2/α2\sigma^2/\alpha^2, the prior variance: the data do not constrain that direction.
    5. Four stations lie on a line, and an earthquake happens off the line. What can go wrong in the location, and why?
      AnswerThe mirror image of the source across the line has exactly the same distances to all stations, so it predicts the same arrival times: the problem has two solutions (uniqueness fails). Gauss–Newton converges to the one on the side of the starting guess. Near the line, the misfit is also very flat across it.
    6. For A(m)=L+diag⁡(m)A(m) = L + \operatorname{diag}(m) with a fixed matrix LL, give the adjoint-state gradient of J=12∥Pu−d∥2J = \tfrac12\|Pu - d\|^2.
      AnswerSolve Au=sAu = s and A⊤λ=−P⊤(Pu−d)A^\top\lambda = -P^\top(Pu - d). Since ∂A/∂mk=ekek⊤\partial A/\partial m_k = e_ke_k^\top, ∂J/∂mk=λkuk\partial J/\partial m_k = \lambda_k u_k: the gradient is the elementwise product λ⊙u\lambda \odot u.
    Recall cardsAnswer in your head first, then reveal. Add the cards to your review deck to see them again just before you would forget.
    1. State Hadamard's three conditions for a well-posed problem.

    2. Write the naive SVD solution of d=Gm+ed = Gm + e and say why it fails.

    3. What are the Tikhonov filter factors?

    4. What does the discrete Picard condition say?

    5. For which prior is Tikhonov regularization the MAP estimate, with noise N(0,σ2I)\mathcal N(0, \sigma^2 I)?

    6. What residual norm does the discrepancy principle aim for?

    7. Write one Gauss–Newton step for min⁡12∥F(m)−d∥2\min \tfrac12\|F(m) - d\|^2.

    8. Give the adjoint-state gradient for A(m)u=sA(m)u = s and J=j(u)J = j(u), and its cost.

    9. Give the FWI gradient for m utt−uxx=sm\,u_{tt} - u_{xx} = s.

    10. When does FWI cycle-skip?

    Open the review →

    9. Interview angle #

    • "Why not just invert the matrix?" — Small singular values amplify the noise by 1/σi1/\sigma_i. Show the singular values and the Picard plot, then regularize.
    • "Explain ridge regression as a Bayesian method." — It is MAP with a Gaussian prior N(0,(σ2/α2)I)\mathcal N(0, (\sigma^2/\alpha^2)I) on the weights; the posterior covariance is σ2(X⊤X+α2I)−1\sigma^2(X^\top X + \alpha^2 I)^{-1}.
    • "How do you choose the regularization weight?" — Discrepancy principle if the noise level is known; L-curve or GCV otherwise; cross-validation on held-out data in ML.
    • "How do you get the gradient for millions of parameters in a PDE-constrained problem?" — The adjoint-state method: one forward and one adjoint solve; derive it with a Lagrangian; check it against finite differences.
    • "What is cycle skipping and how do you avoid it?" — A local minimum when the arrival is off by more than half a period; use low frequencies first, a good starting model, or a misfit that is less oscillatory.

    10. Practice #

    The notebook for this lesson has five exercises, each with a check cell and a folded solution:

    1. Build the blur matrix, see the naive inverse fail, and fix it with truncated SVD and Tikhonov.
    2. Choose α\alpha with the discrepancy principle and with the corner of the L-curve; compare with the best α\alpha.
    3. Locate an earthquake with Gauss–Newton from 5 stations, and compare the uncertainty ellipses of two station geometries.
    4. The adjoint-state gradient for a 1D problem (L+diag⁡(m))u=s(L + \operatorname{diag}(m))u = s with receivers, checked with finite differences.
    5. Misfit curves of a 1D wave simulation for a low and a high frequency: count the local minima (cycle skipping).

    11. Watch and read #

    Ill-posedness and the SVD view of a linear inverse problem.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    Tikhonov regularization and its filter factors.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    The singular value expansion, the Picard condition and why the naive reconstruction fails.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    What full-waveform inversion is and why cycle skipping matters.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play
    The adjoint method for A(p)x=bA(p)x = b, as in Theorem 3.
    Open on YouTube · the player loads from youtube-nocookie.com when you press play