Fourier-based metric , DFT matrix and weight of -FWI
DefinitionArxiv2205_09234_BasicObjects of Section 2.1 of Izzatullah and Alkhalifah (2022).
- Fourier transform. For a waveform , , where is the angular frequency.
- Fourier-based metric (eq. 1). For real and a modelled trace and an observed trace ,
- DFT matrix. For samples, , (unnormalised), and for a sampled trace .
- Sample frequencies. For time step , if and otherwise, .
- Weight matrix. , where for all and whenever or (with ). For the zero-frequency entry is left as an arbitrary nonnegative number, because the paper does not say how the infinite value is replaced.
- Discrete metric. , the integral of eq. (1) replaced by the sum over the DFT frequencies, as in eq. (2).
Formalization Note The paper's display integrates over ; it is read as an integral over the time axis . The DFT normalisation, the quadrature factor between the integral of eq. (1) and the sum of eq. (2), and the zero-frequency weight for are not stated in the paper; the choices above are recorded in the mission description.
import Mathlib
/-!
Izzatullah and Alkhalifah, *ω-FWI: Robust full-waveform inversion with Fourier-based metric*,
arXiv:2205.09234v1 (2022): the angular-frequency Fourier transform and the Fourier-based metric
`L_{p,α}` of Section 2.1 (eq. (1)), and its discrete form on sampled traces with the DFT matrix
`Ω`, the sample frequencies `ω` and the weight matrix `W_α = diag(|ω|^α)` (eq. (2)).
-/
open MeasureTheory
noncomputable section
namespace Arxiv2205_09234
/-- Section 2.1, display before eq. (1), p. 2: the Fourier transform of a waveform `d(t)` in the
angular frequency `ω`, `d̂(ω) = ∫ d(t) exp(-i ω t) dt` (the time axis is the real line). -/
def angFourier (d : ℝ → ℝ) (ω : ℝ) : ℂ :=
∫ t : ℝ, (d t : ℂ) * Complex.exp (-(Complex.I * ((ω * t : ℝ) : ℂ)))
/-- Section 2.1, eq. (1), p. 2: the Fourier-based metric
`L_{p,α}(d_m, d_o) = (∫ |ω|^α |d̂_m(ω) - d̂_o(ω)|^p dω)^{1/p}` of a modelled trace `d_m` and an
observed trace `d_o`. -/
def fourierMetric (p α : ℝ) (dm dobs : ℝ → ℝ) : ℝ :=
(∫ ω : ℝ, |ω| ^ α * ‖angFourier dm ω - angFourier dobs ω‖ ^ p) ^ (1 / p)
/-- Section 2.1, eq. (2), p. 2: the Discrete Fourier Transform matrix `Ω` of size `N = N_t`
(unnormalised), `Ω_{kj} = exp(-2π i k j / N)`. -/
def dftMat (N : ℕ) : Matrix (Fin N) (Fin N) ℂ :=
fun k j => Complex.exp (-(2 * Real.pi * Complex.I * (k : ℂ) * (j : ℂ) / (N : ℂ)))
/-- Section 2.1, eq. (2), p. 2: the DFT `d̂ = Ω d` of a sampled real trace `d ∈ ℝ^{N_t}`. -/
def dft (N : ℕ) (d : Fin N → ℝ) : Fin N → ℂ :=
(dftMat N).mulVec (fun j => (d j : ℂ))
/-- Section 2.1, eq. (2), p. 2: the vector `ω` of the waveform's sample (angular) frequencies for
`N` samples at time step `dt`: `ω_k = 2πk/(N dt)` if `2k < N` and `ω_k = 2π(k - N)/(N dt)`
otherwise (the frequency ordering of the DFT). -/
def sampleFreq (N : ℕ) (dt : ℝ) (k : Fin N) : ℝ :=
2 * Real.pi * (if 2 * (k : ℕ) < N then (k : ℝ) else (k : ℝ) - N) / (N * dt)
/-- Section 2.1, eq. (2), p. 2: `w` is the diagonal of `W_α = diag(|ω|^α)`. Every entry is
nonnegative and equals `|ω_k|^α` wherever this is a real number. The paper does not say what
`W_α` contains at the zero frequency when `α < 0` (where `|0|^α` is infinite), so that entry is
any nonnegative real number. -/
def IsFreqWeight (N : ℕ) (dt α : ℝ) (w : Fin N → ℝ) : Prop :=
(∀ k, 0 ≤ w k) ∧ ∀ k, (sampleFreq N dt k ≠ 0 ∨ 0 ≤ α) → w k = |sampleFreq N dt k| ^ α
/-- Section 2.1, eq. (2), p. 2: the weight matrix `W_α = diag(w)` as a complex matrix. -/
def weightMat {N : ℕ} (w : Fin N → ℝ) : Matrix (Fin N) (Fin N) ℂ :=
Matrix.diagonal (fun k => (w k : ℂ))
/-- Section 2.1, eqs. (1)-(2), p. 2: the Fourier-based metric of eq. (1) on sampled traces, with the
integral over `ω` replaced by the sum over the DFT frequencies as in eq. (2):
`L_{p,α}(d_m, d_o) = (∑_k w_k |d̂_{m,k} - d̂_{o,k}|^p)^{1/p}`, where `w` is the diagonal of `W_α`. -/
def discreteMetric (N : ℕ) (p : ℝ) (w : Fin N → ℝ) (dm dobs : Fin N → ℝ) : ℝ :=
(∑ k, w k * ‖dft N dm k - dft N dobs k‖ ^ p) ^ (1 / p)
end Arxiv2205_09234
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Conventions used throughout.
- Powers of real numbers with real exponent follow these rules:
- for , is the usual power;
- , and for every , including negative ;
- for , .
- Division by zero returns . In particular, when the exponent equals .
- An integral over is the Lebesgue integral. If the integrand is not integrable, the integral is defined to be ; this is a convention, not an error.
- denotes the modulus of a complex number .
Angular-frequency Fourier transform. Take any function and any real . Define
No hypothesis is placed on . Since , the integrand is integrable exactly when is Lebesgue integrable. If is not integrable, then for every .
Continuous Fourier-based metric. Take arbitrary real numbers and , with no sign or size restrictions, and arbitrary functions . Define
with as above. Edge cases:
- At the weight is if and otherwise. This is a single point, so it does not affect the integral.
- Where , the factor is if and otherwise.
- If the integrand is not integrable, the inner integral is . The value is then when .
- If , the outer exponent is , so for all inputs.
DFT matrix. For a natural number , is the complex matrix with rows and columns indexed by and entries
There is no normalising factor. When the matrix is empty.
DFT of a sampled trace. For a real vector , its DFT is the complex vector , with regarded as a complex vector. Componentwise:
Sample frequencies. For a natural number , any real and an index :
with computed as a real number, so it can be negative. No condition is placed on :
- it may be negative;
- if , the denominator is , so every .
Whenever , the first frequency is .
Admissible frequency weight. Given , real and real , a real vector is called a frequency weight if both of the following hold:
- for every ;
- for every with or , we have .
The consequences of these conditions are:
- For an index with and , the only constraint is , so can be any nonnegative real.
- If and , then .
- If and , then .
- If and , every entry is an arbitrary nonnegative real.
- The condition can always be satisfied.
Weight matrix. For any real vector of length , is the complex diagonal matrix with diagonal entries and zeros elsewhere. No condition on is imposed.
Discrete Fourier-based metric. Take a natural number , any real , an arbitrary real vector of length , and real vectors of length . Define
where and are the unnormalised DFTs above. Points to note:
- No link to , or the frequencies. The definition does not require to be a frequency weight in the sense above, and it does not involve , or the frequencies at all.
- Neither nor any frequency spacing is used. The weight enters through directly rather than through the matrix , and there is no factor for the frequency spacing.
- Negative weights. Entries of may be negative. The sum may then be negative, and the power follows the negative-base convention stated at the start.
- Edge cases:
- gives the value ;
- gives an empty sum, so the value is when and when .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.