Random scattering matrices of particle slabs: modes, normalized blocks, ensemble, phases and cascades
DefinitionArxiv2205_09423_BasicObjects of Section 2 and Appendices A–D of Byrnes and Foreman (2022).
- Modes (Section 2.1). A mode set consists of a wavenumber and distinct transverse wavevectors , , with and (so ), each with the cubature weight . Write , , , , , and
if and otherwise; if and otherwise. 2. Polar basis (Eq. 11). For a unit direction : ( if ) and . The reduction of a complex matrix from direction to direction is the matrix . 3. Slab (Eqs. 9–17). A slab contains particles with centres and far-field amplitude matrices (complex ). Its discretized transmission and reflection matrices are and ; , are their reductions (Eqs. 12–13), and , their normalizations. The normalized blocks are
with , the reductions of and . For incidence from the right, and , with incident direction and outgoing directions , . The blocks are assembled as in Eq. (16) (block row , block column ) and . 4. Ensemble (Section 2.2). On a probability space, the pairs are independent across particles, is independent of , the are identically distributed with square-integrable entries, the coordinate of is uniform on and independent of the transverse position , , , and for every
Covariance: ; pseudo-covariance: . , . 5. Position and cascades (Section 2.3, Appendices B, C). Translating every particle by moves the slab centre to . , , , . The transfer matrix of is . is the exchange matrix, , and is reciprocal if with . is the cascade of (left) and (right) if for all incoming amplitudes (left) and (right) there are amplitudes between the slabs with , , and . 6. Scattering plane (Appendix D). For incident and outgoing unit directions : , , ; if , then , , . is the signed angle from to about , , and is the matrix of between the frames and with (Bohren–Huffman convention).
Formalization Note Mode is indexed by , so mode is the reversed index and is the reversal. Polarization index is , is . The blocks , are not printed in the paper ("analogous expressions"). They are written by analogy with Eqs. (14)–(15), using the phases implied by Table A1. The transfer-matrix convention is not written in the paper; Beenakker's convention, which the paper cites, is used. The reciprocity relation is taken from Byrnes and Foreman, Phys. Rev. Research 3, 013129 (2021), Eq. (98). The signed angle is the argument of , which also covers , a value the paper's range leaves out.
import Mathlib
/-!
N. Byrnes and M. R. Foreman, *Random matrix theory of polarized light scattering in disordered
media*, arXiv:2205.09423v1 (2022).
Definitions for Section 2 (Eqs. (9)–(17), (19), (22)–(28)) and Appendices A–D: the discrete mode
set, the polar basis of Eq. (11), the transmission and reflection matrices of a slab of particles in
the single-scattering approximation and their normalized `2 × 2` blocks, the block scattering matrix,
the ensemble assumptions of Section 2.2, covariances and pseudo-covariances, the propagation phase
matrices of Appendix C, the transfer matrix, reciprocity, the cascade of two slabs (Appendix B) and
the scattering-plane frames of Appendix D.
Mode `i : Fin (2 * Nk + 1)` stands for the paper's index `i - Nk ∈ {-Nk, …, Nk}`, so the paper's
mode `-i` is `Fin.rev i`. Polarization index `0` is `θ` and `1` is `φ`.
-/
open MeasureTheory ProbabilityTheory Matrix
noncomputable section
namespace Arxiv2205_09423
/-- Section 2.1, p. 5: the discrete mode set `K = {-κ_{N_k}, …, -κ_1, 0, κ_1, …, κ_{N_k}}` of
transverse wavevectors `κ_i = (kx i, ky i)`, the wavenumber `k = 2π/λ` and the common cubature
weight `w`. -/
structure ModeSet (Nk : ℕ) where
/-- wavenumber `k = 2π/λ` -/
k : ℝ
/-- `x` components of the transverse wavevectors -/
kx : Fin (2 * Nk + 1) → ℝ
/-- `y` components of the transverse wavevectors -/
ky : Fin (2 * Nk + 1) → ℝ
/-- cubature weight of every mode -/
w : ℝ
namespace ModeSet
variable {Nk : ℕ} (K : ModeSet Nk)
/-- Section 2.1, pp. 4–5: `k > 0`; every mode is a homogeneous plane wave, `|κ_i| < k`; modes come
in inverse pairs, `κ_{-i} = -κ_i` (so `κ_0 = 0`); the `2 N_k + 1` modes are distinct; and the equal
weights are `w = π k² / (2 N_k + 1)`. -/
def IsValid : Prop :=
0 < K.k ∧ (∀ i, K.kx i ^ 2 + K.ky i ^ 2 < K.k ^ 2) ∧
(∀ i, K.kx (Fin.rev i) = -K.kx i ∧ K.ky (Fin.rev i) = -K.ky i) ∧
Function.Injective (fun i => (K.kx i, K.ky i)) ∧
K.w = Real.pi * K.k ^ 2 / (2 * Nk + 1)
/-- Section 2.1, p. 4: `k_{iz} = (k² - k_{ix}² - k_{iy}²)^{1/2}`. -/
def kz (i : Fin (2 * Nk + 1)) : ℝ := Real.sqrt (K.k ^ 2 - K.kx i ^ 2 - K.ky i ^ 2)
/-- Section 2.1, p. 4: the right-propagating wavevector `k_i = (k_{ix}, k_{iy}, k_{iz})`. -/
def kvec (i : Fin (2 * Nk + 1)) : Fin 3 → ℝ := ![K.kx i, K.ky i, K.kz i]
/-- Section 2.1, p. 5: the left-propagating wavevector `k̃_i = (k_{ix}, k_{iy}, -k_{iz})`. -/
def kvecT (i : Fin (2 * Nk + 1)) : Fin 3 → ℝ := ![K.kx i, K.ky i, -K.kz i]
/-- Eq. (14), p. 6: `C_{ji} = w / (2π k √(k_{jz} k_{iz}))`. -/
def cji (j i : Fin (2 * Nk + 1)) : ℝ :=
K.w / (2 * Real.pi * K.k * Real.sqrt (K.kz j * K.kz i))
/-- Eq. (25), p. 8: `C_{ijuv} = w n ΔL / (k² √(k_{iz} k_{jz} k_{uz} k_{vz}))`, for particle
density `n` and slab thickness `ΔL = dL`. -/
def cijuv (n dL : ℝ) (i j u v : Fin (2 * Nk + 1)) : ℝ :=
K.w * n * dL / (K.k ^ 2 * Real.sqrt (K.kz i * K.kz j * K.kz u * K.kz v))
/-- Eqs. (24)–(25), p. 8: `δ^R = 1` when `k_{ix} - k_{jx} = k_{ux} - k_{vx}` and
`k_{iy} - k_{jy} = k_{uy} - k_{vy}` (the memory-effect condition), and `0` otherwise. -/
def deltaR (i j u v : Fin (2 * Nk + 1)) : ℝ :=
if K.kx i - K.kx j = K.kx u - K.kx v ∧ K.ky i - K.ky j = K.ky u - K.ky v then 1 else 0
/-- Eqs. (27)–(28), p. 9: `δ^P = 1` when `k_{ix} - k_{jx} = -(k_{ux} - k_{vx})` and
`k_{iy} - k_{jy} = -(k_{uy} - k_{vy})`, and `0` otherwise. -/
def deltaP (i j u v : Fin (2 * Nk + 1)) : ℝ :=
if K.kx i - K.kx j = -(K.kx u - K.kx v) ∧ K.ky i - K.ky j = -(K.ky u - K.ky v) then 1 else 0
end ModeSet
/-- Euclidean norm `|v|` of a vector of `ℝ³`. -/
def vnorm (v : Fin 3 → ℝ) : ℝ := Real.sqrt (dotProduct v v)
/-- The unit vector `v / |v|`. -/
def normalize (v : Fin 3 → ℝ) : Fin 3 → ℝ := (vnorm v)⁻¹ • v
/-- The unit vector `ẑ`. -/
def zhat : Fin 3 → ℝ := ![0, 0, 1]
/-- Eq. (11), p. 5: `e_φ = (ẑ × e_k)/|ẑ × e_k|` for the unit propagation direction `e_k`, with
`e_φ = ±ŷ` in the special cases `e_k = ±ẑ`. -/
def ePhi (e : Fin 3 → ℝ) : Fin 3 → ℝ :=
if e 0 = 0 ∧ e 1 = 0 then (if 0 < e 2 then ![0, 1, 0] else ![0, -1, 0])
else normalize (crossProduct zhat e)
/-- Eq. (11), p. 5: `e_θ = (e_φ × e_k)/|e_φ × e_k|`. -/
def eTheta (e : Fin 3 → ℝ) : Fin 3 → ℝ := normalize (crossProduct (ePhi e) e)
/-- Eq. (11): the polarization basis `(e_θ, e_φ)` attached to the unit direction `e`. -/
def polarBasis (e : Fin 3 → ℝ) : Fin 2 → Fin 3 → ℝ := ![eTheta e, ePhi e]
/-- Eq. (2), p. 4: the far-field amplitude of one particle, `A(u_out, u_in)`, a `3 × 3` complex
matrix (entries `a b`) for each observation direction `u_out` and incidence direction `u_in`. -/
abbrev Amp := (Fin 3 → ℝ) → (Fin 3 → ℝ) → Fin 3 → Fin 3 → ℂ
/-- Eqs. (12)–(13), p. 5: the reduced `2 × 2` matrix `[e_m(u_out)ᵀ X e_n(u_in)]_{m n}` of a
`3 × 3` matrix `X`, in the polar bases of the incident direction `u_in` and outgoing direction
`u_out`. -/
def reduce (X : Fin 3 → Fin 3 → ℂ) (uin uout : Fin 3 → ℝ) : Matrix (Fin 2) (Fin 2) ℂ :=
Matrix.of fun m n => ∑ a, ∑ b, (polarBasis uout m a : ℂ) * X a b * (polarBasis uin n b : ℂ)
section Slab
variable {Nk : ℕ} (K : ModeSet Nk) {N : ℕ}
/-- Eq. (9), p. 5: the discretized `3 × 3` transmission matrix of a slab containing `N` particles
with centres `r p` and amplitudes `A p`:
`t(κ_j, κ_i) = (δ_{ij}/w) I₃ + (2π k k_{jz})⁻¹ ∑_p A_p(u_j, u_i) e^{i(k_i - k_j)·r_p}`. -/
def tMat3 (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Fin 3 → Fin 3 → ℂ :=
fun a b => (if i = j then ((K.w : ℂ)⁻¹ * (if a = b then 1 else 0)) else 0) +
((2 * Real.pi * K.k * K.kz j : ℝ) : ℂ)⁻¹ *
∑ p, A p (K.k⁻¹ • K.kvec j) (K.k⁻¹ • K.kvec i) a b *
Complex.exp (Complex.I * ((dotProduct (K.kvec i - K.kvec j) (r p) : ℝ) : ℂ))
/-- Eq. (10), p. 5: the discretized `3 × 3` reflection matrix
`r(κ_j, κ_i) = (2π k k_{jz})⁻¹ ∑_p A_p(ũ_j, u_i) e^{i(k_i - k̃_j)·r_p}`. -/
def rMat3 (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Fin 3 → Fin 3 → ℂ :=
fun a b => ((2 * Real.pi * K.k * K.kz j : ℝ) : ℂ)⁻¹ *
∑ p, A p (K.k⁻¹ • K.kvecT j) (K.k⁻¹ • K.kvec i) a b *
Complex.exp (Complex.I * ((dotProduct (K.kvec i - K.kvecT j) (r p) : ℝ) : ℂ))
/-- Eq. (14), first equality, p. 6: `t̄_{(j,i)} = √(k_{jz}/k_{iz}) t_{(j,i)} w`, where `t_{(j,i)}` is
the reduction (12) of the matrix (9). -/
def tNorm (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
((Real.sqrt (K.kz j / K.kz i) * K.w : ℝ) : ℂ) •
reduce (tMat3 K A r j i) (K.k⁻¹ • K.kvec i) (K.k⁻¹ • K.kvec j)
/-- Eq. (15), first equality, p. 6: `r̄_{(j,i)} = √(k_{jz}/k_{iz}) r_{(j,i)} w`, where `r_{(j,i)}` is
the reduction (13) of the matrix (10). -/
def rNorm (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
((Real.sqrt (K.kz j / K.kz i) * K.w : ℝ) : ℂ) •
reduce (rMat3 K A r j i) (K.k⁻¹ • K.kvec i) (K.k⁻¹ • K.kvecT j)
/-- Eqs. (14)–(15), p. 6: the reduced single-particle matrix `A_{(j,i)}` ("defined analogously to
`t_{(j,i)}`") for incident wavevector `vin i` and outgoing wavevector `vout j`:
`A^t_{(j,i)}` is `ampRed K X K.kvec K.kvec j i`, `A^r_{(j,i)}` is `ampRed K X K.kvec K.kvecT j i`. -/
def ampRed (X : Amp) (vin vout : Fin (2 * Nk + 1) → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
reduce (X (K.k⁻¹ • vout j) (K.k⁻¹ • vin i)) (K.k⁻¹ • vin i) (K.k⁻¹ • vout j)
/-- Eqs. (14)–(15), p. 6: the scattered part `C_{ji} ∑_p A_{p(j,i)} e^{i(vin_i - vout_j)·r_p}`
of a normalized block, for incident wavevectors `vin` and outgoing wavevectors `vout`. -/
def blockSum (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (vin vout : Fin (2 * Nk + 1) → Fin 3 → ℝ)
(j i : Fin (2 * Nk + 1)) : Matrix (Fin 2) (Fin 2) ℂ :=
((K.cji j i : ℝ) : ℂ) • ∑ p,
Complex.exp (Complex.I * ((dotProduct (vin i - vout j) (r p) : ℝ) : ℂ)) •
ampRed K (A p) vin vout j i
/-- Eq. (14), second equality, p. 6: the normalized transmission block
`t̄_{(j,i)} = δ_{ij} I₂ + C_{ji} ∑_p A^t_{p(j,i)} e^{i(k_i - k_j)·r_p}`. -/
def tbar (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
(if i = j then 1 else 0) + blockSum K A r K.kvec K.kvec j i
/-- Eq. (15), second equality, p. 6: the normalized reflection block
`r̄_{(j,i)} = C_{ji} ∑_p A^r_{p(j,i)} e^{i(k_i - k̃_j)·r_p}`. -/
def rbar (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
blockSum K A r K.kvec K.kvecT j i
/-- Section 2.1, p. 6 ("analogous expressions … for a left-propagating plane wave incident upon the
right side"; not printed in the paper): the normalized transmission block for incidence from the
right, `t̄'_{(j,i)} = δ_{ij} I₂ + C_{ji} ∑_p A^{t'}_{p(j,i)} e^{i(k̃_i - k̃_j)·r_p}`, with incident
direction `ũ_i` and outgoing direction `ũ_j`; these are the phases of Table A1, p. 24. -/
def tpbar (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
(if i = j then 1 else 0) + blockSum K A r K.kvecT K.kvecT j i
/-- Section 2.1, p. 6 (not printed in the paper, see `tpbar`): the normalized reflection block for
incidence from the right, `r̄'_{(j,i)} = C_{ji} ∑_p A^{r'}_{p(j,i)} e^{i(k̃_i - k_j)·r_p}`, with
incident direction `ũ_i` and outgoing direction `u_j`. -/
def rpbar (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) (j i : Fin (2 * Nk + 1)) :
Matrix (Fin 2) (Fin 2) ℂ :=
blockSum K A r K.kvecT K.kvec j i
end Slab
/-- Index set of the rows of `t̄` in Eq. (16): a mode and a polarization (`θ = 0`, `φ = 1`). -/
abbrev MIdx (Nk : ℕ) := Fin (2 * Nk + 1) × Fin 2
/-- Eq. (16), p. 6: the full matrix built from the `2 × 2` blocks `B_{(j,i)}`, block row `j`,
block column `i`. -/
def assemble {Nk : ℕ} (B : Fin (2 * Nk + 1) → Fin (2 * Nk + 1) → Matrix (Fin 2) (Fin 2) ℂ) :
Matrix (MIdx Nk) (MIdx Nk) ℂ :=
Matrix.of fun x y => B x.1 y.1 x.2 y.2
/-- Eq. (17), p. 6: the normalized scattering matrix `S̄ = [[r̄, t̄'], [t̄, r̄']]` of a slab. -/
def sMat {Nk N : ℕ} (K : ModeSet Nk) (A : Fin N → Amp) (r : Fin N → Fin 3 → ℝ) :
Matrix (MIdx Nk ⊕ MIdx Nk) (MIdx Nk ⊕ MIdx Nk) ℂ :=
Matrix.fromBlocks (assemble (rbar K A r)) (assemble (tpbar K A r)) (assemble (tbar K A r))
(assemble (rpbar K A r))
/-- Section 2.2, pp. 6–7: the ensemble of slabs of thickness `ΔL = dL` and particle density `n`.
On the probability space `(Ω, P)`, particle `p` has centre `r p` and amplitude `A p`, and:
the particles are statistically independent; each particle's morphology is independent of its
position; the amplitudes are identically distributed (with finite second moments); the `z`
coordinate of each centre is uniform on `[-ΔL/2, ΔL/2]` and independent of the transverse
position (uniform distribution in the slab); and the transverse phase averages obey the paper's
discretization of Eq. (19), `N ⟨e^{i q·ρ}⟩ = (2π)² n ΔL δ_{q,0} / w`, for every transverse vector
`q = κ_i - κ_j - κ_u + κ_v` built from the modes (the replacement
`δ(q_x) δ(q_y) → δ_{q,0}/w` of p. 7, made after the limit `N, V → ∞` at fixed `n = N/V`). -/
def IsSlabEnsemble {Nk : ℕ} (K : ModeSet Nk) (dL n : ℝ) {Ω : Type*} [MeasurableSpace Ω]
(P : Measure Ω) {N : ℕ} (r : Fin N → Ω → Fin 3 → ℝ) (A : Fin N → Ω → Amp) : Prop :=
IsProbabilityMeasure P ∧ 0 < dL ∧ 0 < n ∧
(∀ p, Measurable (r p)) ∧ (∀ p, Measurable (A p)) ∧
iIndepFun (fun p ω => (r p ω, A p ω)) P ∧
(∀ p, IndepFun (r p) (A p) P) ∧
(∀ p q, IdentDistrib (A p) (A q) P P) ∧
(∀ p uo ui a b, MemLp (fun ω => A p ω uo ui a b) 2 P) ∧
(∀ p, IndepFun (fun ω => (r p ω 0, r p ω 1)) (fun ω => r p ω 2) P) ∧
(∀ p, pdf.IsUniform (fun ω => r p ω 2) (Set.Icc (-dL / 2) (dL / 2)) P) ∧
(∀ p i j u v,
(N : ℂ) * ∫ ω, Complex.exp (Complex.I *
((((K.kx i - K.kx j - K.kx u + K.kx v) * r p ω 0 +
(K.ky i - K.ky j - K.ky u + K.ky v) * r p ω 1 : ℝ)) : ℂ)) ∂P =
if K.kx i - K.kx j - K.kx u + K.kx v = 0 ∧ K.ky i - K.ky j - K.ky u + K.ky v = 0 then
(((2 * Real.pi) ^ 2 * n * dL / K.w : ℝ) : ℂ)
else 0)
/-- Eq. (25), left side, p. 8: the covariance `⟨X Y*⟩ - ⟨X⟩⟨Y*⟩` of two complex random
variables. -/
def covC {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω) (X Y : Ω → ℂ) : ℂ :=
(∫ ω, X ω * star (Y ω) ∂P) - (∫ ω, X ω ∂P) * star (∫ ω, Y ω ∂P)
/-- Eq. (27), left side, p. 9: the pseudo-covariance `⟨X Y⟩ - ⟨X⟩⟨Y⟩` (no complex conjugate). -/
def pcovC {Ω : Type*} [MeasurableSpace Ω] (P : Measure Ω) (X Y : Ω → ℂ) : ℂ :=
(∫ ω, X ω * Y ω ∂P) - (∫ ω, X ω ∂P) * (∫ ω, Y ω ∂P)
/-- Appendix C, p. 25: the slab moved rigidly so that every particle centre is translated by
`L₀` along `z`. -/
def shiftZ {N : ℕ} (L0 : ℝ) (r : Fin N → Fin 3 → ℝ) : Fin N → Fin 3 → ℝ :=
fun p => r p + ![0, 0, L0]
/-- Eq. (C1), p. 25: `Λ₊^{L₀} = diag(e^{i k_{-N_k z} L₀}, …, e^{i k_{N_k z} L₀}) ⊗ I₂`. -/
def lamPlus {Nk : ℕ} (K : ModeSet Nk) (L0 : ℝ) : Matrix (MIdx Nk) (MIdx Nk) ℂ :=
Matrix.kroneckerMap (· * ·)
(Matrix.diagonal fun i => Complex.exp (Complex.I * ((K.kz i * L0 : ℝ) : ℂ)))
(1 : Matrix (Fin 2) (Fin 2) ℂ)
/-- Appendix C, p. 25: `Λ₋^{L₀} = (Λ₊^{L₀})*` (entrywise complex conjugate). -/
def lamMinus {Nk : ℕ} (K : ModeSet Nk) (L0 : ℝ) : Matrix (MIdx Nk) (MIdx Nk) ℂ :=
(lamPlus K L0).map star
/-- Appendix C, p. 25: `Λ_±^{L₀} = diag(Λ₊^{L₀}, Λ₋^{L₀})`. -/
def lamPM {Nk : ℕ} (K : ModeSet Nk) (L0 : ℝ) :
Matrix (MIdx Nk ⊕ MIdx Nk) (MIdx Nk ⊕ MIdx Nk) ℂ :=
Matrix.fromBlocks (lamPlus K L0) 0 0 (lamMinus K L0)
/-- Appendix C, p. 25: `Λ_∓^{L₀} = (Λ_±^{L₀})*` (entrywise complex conjugate). -/
def lamMP {Nk : ℕ} (K : ModeSet Nk) (L0 : ℝ) :
Matrix (MIdx Nk ⊕ MIdx Nk) (MIdx Nk ⊕ MIdx Nk) ℂ :=
(lamPM K L0).map star
/-- Section 2.3, p. 10 (the paper cites Beenakker, Rev. Mod. Phys. 69, 731 (1997), and does not
write the convention out): the transfer matrix of `S = [[r, t'], [t, r']]`, which maps the
right- and left-propagating amplitudes on the left of the slab to those on its right,
`M = [[t - r' t'⁻¹ r, r' t'⁻¹], [-t'⁻¹ r, t'⁻¹]]` (meaningful when `t'` is invertible). -/
def transfer {V : Type*} [Fintype V] [DecidableEq V] (S : Matrix (V ⊕ V) (V ⊕ V) ℂ) :
Matrix (V ⊕ V) (V ⊕ V) ℂ :=
Matrix.fromBlocks (S.toBlocks₂₁ - S.toBlocks₂₂ * S.toBlocks₁₂⁻¹ * S.toBlocks₁₁)
(S.toBlocks₂₂ * S.toBlocks₁₂⁻¹) (-(S.toBlocks₁₂⁻¹ * S.toBlocks₁₁)) S.toBlocks₁₂⁻¹
/-- Appendix B, p. 25: the `n × n` exchange matrix `J_n`, with ones on the anti-diagonal. -/
def exch (n : ℕ) : Matrix (Fin n) (Fin n) ℂ := Matrix.of fun a b => if a = Fin.rev b then 1 else 0
/-- Appendix B, p. 25: `σ_z = diag(1, -1)`. -/
def sigmaZ : Matrix (Fin 2) (Fin 2) ℂ := Matrix.diagonal ![1, -1]
/-- Appendix B, p. 25: `J_{2N_k+1} ⊗ σ_z`. -/
def piMat (Nk : ℕ) : Matrix (MIdx Nk) (MIdx Nk) ℂ :=
Matrix.kroneckerMap (· * ·) (exch (2 * Nk + 1)) sigmaZ
/-- Reciprocity of a normalized scattering matrix, used in Appendix B (p. 25) and Section 2.3
(p. 10), as derived in Byrnes and Foreman, Phys. Rev. Research 3, 013129 (2021), Eq. (98):
`S̄ = Π S̄ᵀ Π` with `Π = diag(J ⊗ σ_z, J ⊗ σ_z)`; blockwise `r̄ = (J⊗σ_z) r̄ᵀ (J⊗σ_z)`,
`t̄' = (J⊗σ_z) t̄ᵀ (J⊗σ_z)`, `r̄' = (J⊗σ_z) r̄'ᵀ (J⊗σ_z)`. -/
def IsReciprocal {Nk : ℕ} (S : Matrix (MIdx Nk ⊕ MIdx Nk) (MIdx Nk ⊕ MIdx Nk) ℂ) : Prop :=
S = Matrix.fromBlocks (piMat Nk) 0 0 (piMat Nk) * S.transpose *
Matrix.fromBlocks (piMat Nk) 0 0 (piMat Nk)
/-- Appendix B, p. 24: `S` is the scattering matrix of the system made of slab 1 (scattering matrix
`S₁ = [[r₁, t₁'], [t₁, r₁']]`) to the left of slab 2 (`S₂`): for all incoming amplitudes `a` (from
the left) and `d` (from the right) there are amplitudes `b` (right-propagating) and `c`
(left-propagating) between the slabs such that `b = t₁ a + r₁' c`, `c = r₂ b + t₂' d`, and `S`
maps `(a, d)` to the outgoing amplitudes `(r₁ a + t₁' c, t₂ b + r₂' d)`. -/
def IsCascade {V : Type*} [Fintype V] (S1 S2 S : Matrix (V ⊕ V) (V ⊕ V) ℂ) : Prop :=
∀ a d : V → ℂ, ∃ b c : V → ℂ,
b = S1.toBlocks₂₁ *ᵥ a + S1.toBlocks₂₂ *ᵥ c ∧
c = S2.toBlocks₁₁ *ᵥ b + S2.toBlocks₁₂ *ᵥ d ∧
S *ᵥ Sum.elim a d =
Sum.elim (S1.toBlocks₁₁ *ᵥ a + S1.toBlocks₁₂ *ᵥ c) (S2.toBlocks₂₁ *ᵥ b + S2.toBlocks₂₂ *ᵥ d)
/-- Appendix D, p. 26: the unit normal `e_⊥ = (e_{ki} × e_{kj})/|e_{ki} × e_{kj}|` of the
scattering plane of incident direction `ui` and outgoing direction `uj`; when the two directions
are parallel (cross product zero), `e_⊥ = e_{φ i}`. -/
def ePerp (ui uj : Fin 3 → ℝ) : Fin 3 → ℝ :=
if crossProduct ui uj = 0 then ePhi ui else normalize (crossProduct ui uj)
/-- Appendix D, p. 26: `e_{∥ i} = e_⊥ × e_{ki}`, and `e_{∥ i} = e_{θ i}` when the directions are
parallel. -/
def eParIn (ui uj : Fin 3 → ℝ) : Fin 3 → ℝ :=
if crossProduct ui uj = 0 then eTheta ui else crossProduct (ePerp ui uj) ui
/-- Appendix D, p. 26: `e_{∥ j} = e_⊥ × e_{kj}`, and `e_{∥ j} = e_{θ j}` when the directions are
parallel. -/
def eParOut (ui uj : Fin 3 → ℝ) : Fin 3 → ℝ :=
if crossProduct ui uj = 0 then eTheta uj else crossProduct (ePerp ui uj) uj
/-- Appendix D, p. 26: the signed angle `θ` from `e_θ` to `e_∥` about the propagation direction
`e_k`: `|θ|` is the angle between them and `θ > 0` when `e_θ × e_∥` points along `e_k`
(the argument of `⟨e_θ, e_∥⟩ + i ⟨e_θ × e_∥, e_k⟩`, in `(-π, π]`). -/
def signedAngle (eth epar ek : Fin 3 → ℝ) : ℝ :=
Complex.arg ⟨dotProduct eth epar, dotProduct (crossProduct eth epar) ek⟩
/-- Eq. (D1), p. 26: `R(θ) = [[cos θ, sin θ], [-sin θ, cos θ]]`. -/
def rotM (t : ℝ) : Matrix (Fin 2) (Fin 2) ℂ :=
!![(Real.cos t : ℂ), (Real.sin t : ℂ); (-(Real.sin t) : ℂ), (Real.cos t : ℂ)]
/-- Appendix D, p. 26: the amplitude matrix `[[S₂, S₃], [S₄, S₁]]` of a `3 × 3` matrix `X` with
respect to the scattering plane, in the convention of Bohren and Huffman: components along
`(e_∥, e'_⊥)` with `e'_⊥ = -e_⊥`, for incidence direction `ui` and outgoing direction `uj`. -/
def ampScatPlane (X : Fin 3 → Fin 3 → ℂ) (ui uj : Fin 3 → ℝ) : Matrix (Fin 2) (Fin 2) ℂ :=
Matrix.of fun m n => ∑ a, ∑ b,
((![eParOut ui uj, -ePerp ui uj] m a : ℝ) : ℂ) * X a b *
((![eParIn ui uj, -ePerp ui uj] n b : ℝ) : ℂ)
end Arxiv2205_09423
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Conventions used throughout. is a natural number and the mode index ranges over the finite set , which has elements. For write for the reversed index. Polarization indices range over . Every division and every inverse of a real or complex number returns when . Every square root of a real number returns when .
Mode set (). A mode set for a given consists of four pieces of data, with no constraints imposed:
- a real number ;
- two real-valued families and ;
- a real number .
Validity (). A mode set is valid when all of the following hold:
- .
- for every .
- and for every . Because , this forces .
- The map is injective, so the transverse vectors are pairwise distinct.
- .
Longitudinal wavenumber (). It is defined as
This value is always . It is , not imaginary, whenever the radicand is negative. Under validity it is strictly positive.
Wavevectors. The two wavevectors attached to mode are
Coefficient . It is defined as
It equals if the denominator vanishes, for example when or some .
Coefficient . For real parameters and , and indices ,
It equals if the denominator vanishes.
Indicator . It equals if both
hold as exact real equalities, and otherwise.
Indicator . It equals if both
hold exactly, and otherwise.
Norm and normalization. For , and . The zero vector normalizes to the zero vector. Also .
. This is defined for an arbitrary ; is not assumed to be a unit vector.
- If : when , and otherwise. In particular, gives .
- Otherwise: is the normalization of .
. It is the normalization of . The polar basis of is the ordered pair .
Amplitude function. An amplitude function assigns a complex matrix to every ordered pair of vectors . No regularity or symmetry is required.
Reduction. For a complex matrix and vectors , the reduction is the complex matrix
Here is the polar basis of just defined. The vectors are not required to be unit vectors.
Slab data. Throughout this part, fix a mode set (not assumed valid) and a number of particles. Particle has an amplitude function and a centre . All sums over run over these particles and are empty if .
transmission matrix . Its entry is
Both prefactors become if their denominators vanish.
reflection matrix . Its entry is
and . These are complex matrices:
These are separate definitions. Nothing in the code relates them to and below.
Reduced single-particle matrix . For an amplitude function and families of vectors , in ,
Block sum. It is defined as
Normalized blocks. These are the four complex matrices below, where is the identity:
Assembly. Combined indices are pairs with and ; there are of them. Given blocks , the assembled matrix has entries
Scattering matrix . It is the square matrix indexed by two copies of the combined index set:
Here are the assemblies of .
Slab ensemble (). The inputs are:
- a mode set ;
- reals and ;
- a measure on a measurable space ;
- for each particle , a random centre with coordinates ;
- for each , a random amplitude function on .
The condition holds when all of the following are true:
- is a probability measure.
- and .
- Every and every is measurable.
- The pairs , , are mutually independent.
- For each , is independent of .
- All have the same law. No such condition is imposed on the .
- For every , every pair of vectors and every entry , the random variable is square-integrable.
- For each , is independent of .
- Each is uniformly distributed on .
- For every and every , with
the following holds:
Consequences of these conditions:
- When : every per-particle condition is vacuous.
- The case: taking always gives . The left side is then , so for the condition forces the exact identity . If , the right side is , which is impossible for .
- The case: for every nonzero of the displayed form, the characteristic function of must vanish exactly at .
- Validity: is not required to be valid.
Covariance. For complex random variables on ,
Pseudo-covariance. It is defined as
In both formulas, any expectation of a non-integrable function is taken to be . No integrability is assumed.
Shift along . For a real , the shift replaces each centre by .
Phase matrices. For real , the following are defined on the combined index set:
The second form of holds because conjugating twice returns .
Transfer matrix. Let be any finite index set, and write a square complex matrix indexed by two copies of in blocks as
Its transfer matrix is
Here denotes the matrix inverse when is invertible and the zero matrix otherwise. So for singular , the formula gives
Exchange and Pauli matrices. The exchange matrix is the matrix with if and otherwise. Also , and
Reciprocity (). A square complex matrix indexed by two copies of the combined index set is reciprocal when
where is the plain transpose, with no conjugation.
Cascade (). For three square complex matrices indexed by two copies of a finite set , write the blocks of as
is a cascade of and when, for all vectors , there exist such that
Consequences of these conditions:
- Existence only: the code requires that some pair exists. It does not require that be unique.
- When the system has no solution: if the first two equations have no solution for some , then the condition fails for every .
Scattering-plane frame. For , not assumed unit, define , and in two cases:
- "Parallel" case, : this includes and antiparallel and either one zero. Then
- Otherwise:
The last two vectors are not normalized.
Signed angle. For vectors , the signed angle is
It equals when both components vanish. No orthonormality of the inputs is assumed.
Rotation matrix. For real , it is the complex matrix
Scattering-plane amplitude matrix. For a complex matrix and vectors , it is the complex matrix
All three vectors are those of the frame built from .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.