Stokes vectors, rotation matrices, transport and streaming operators for graded index media
DefinitionArxiv1110_5134_BasicObjects of Zhao, Tan and Liu (2011), arXiv:1110.5134.
-
Stokes vector (Eq. 1). A beam of intensity whose polarization ellipse has ellipticity angle and orientation angle , measured in a right-hand frame, has Stokes vector .
-
Torsion matrix (Eq. 14). is the matrix with , and all other entries , where is the torsion of the ray.
-
Rotation matrices (Eqs. 23, 31). has rows , , , . The same matrix written through for has and . With , the modified rotation matrix is .
-
Left-hand frame (Eq. 64). .
-
Transport operator and source (Eq. 20). Along a ray with arc length and refractive index , the transport operator is . Directions are unit vectors of with the solid-angle measure (total mass ). The scattering source is . The derivative of a matrix-valued function of is taken entrywise.
-
Frenet frame of a ray (Eq. 46). For a ray with unit tangent : curvature , principal normal , binormal , and torsion (the paper's sign convention).
-
Eulerian streaming operators (Eqs. 42, 49, 52, 55). A field depends on three spatial coordinates and the direction angles. In the local orthonormal frame of the coordinate system, , , and the polar axis is the third frame vector. The gradient components are
- Cartesian : ;
- traditional cylindrical with frame : ;
- new cylindrical with frame : ;
- spherical with frame : .
With , each streaming operator is , plus the coordinate terms printed in Eqs. (49), (52) and (55), plus . The conservative angular term is .
Formalization Note Vectors of are triples of components, with and the cross product of Mathlib. Partial derivatives are derivatives of one-variable slices. The modified rotation matrix is encoded with in front of both terms; as printed, Eq. (31) puts before the first term only (see the report). The streaming operators of Eqs. (42), (49), (52) and (55) are quoted by the paper from Refs. [26], [29], [30] and are taken here as definitions.
import Mathlib
/-!
J. M. Zhao, J. Y. Tan and L. H. Liu, *On the Derivation of Vector Radiative Transfer Equation for
Polarized Radiative Transport in Graded Index Media*, arXiv:1110.5134v1 (2011).
Objects of the paper: the Stokes vector of a polarization ellipse (Eq. 1), the torsion matrix
`R` (Eq. 14), the Stokes rotation matrix (Eq. 23) and the modified rotation matrix (Eq. 31), the
right-hand/left-hand transformation `T` (Eq. 64), the transport operator `n² d/ds [I/n²]` and the
scattering source term of Eq. (20), the Frenet frame and torsion of a ray (Eq. 46), and the
Eulerian streaming operators of Section 4.2.2 (Eqs. 42, 49, 52, 55).
-/
open MeasureTheory
open scoped Matrix
noncomputable section
namespace Arxiv1110_5134
/-- Section 2.1: a Stokes vector `(I, Q, U, V)`. -/
abbrev Stokes := Fin 4 → ℝ
/-- Eq. (1): the Stokes vector of an elliptically polarized beam of intensity `I`, ellipticity angle
`χ` and orientation angle `ψ`, defined in a right-hand frame:
`(I, I cos 2χ cos 2ψ, I cos 2χ sin 2ψ, I sin 2χ)`. -/
def stokesVec (I χ ψ : ℝ) : Stokes :=
![I, I * Real.cos (2 * χ) * Real.cos (2 * ψ), I * Real.cos (2 * χ) * Real.sin (2 * ψ),
I * Real.sin (2 * χ)]
/-- Eq. (14): the matrix `R` accounting for the rotation of the polarization ellipse by Rytov's law,
with `R₂₃ = 2κ`, `R₃₂ = -2κ` and all other entries zero (`κ` the torsion of the ray). -/
def rytovMatrix (κ : ℝ) : Matrix (Fin 4) (Fin 4) ℝ :=
!![0, 0, 0, 0; 0, 0, 2 * κ, 0; 0, -(2 * κ), 0, 0; 0, 0, 0, 0]
/-- Eq. (23): the rotation matrix `ℜ(φ)` of Stokes vectors. -/
def stokesRot (φ : ℝ) : Matrix (Fin 4) (Fin 4) ℝ :=
!![1, 0, 0, 0;
0, Real.cos (2 * φ), Real.sin (2 * φ), 0;
0, -Real.sin (2 * φ), Real.cos (2 * φ), 0;
0, 0, 0, 1]
/-- Text after Eq. (23): the rotation matrix `ℜ(φ)` written through `c = cos φ` alone, using
`cos 2φ = 2c² - 1` and `sin 2φ = 2 sin φ cos φ` with `sin φ = √(1 - c²)` for `φ ∈ [0, π]`. -/
def stokesRotOfCos (c : ℝ) : Matrix (Fin 4) (Fin 4) ℝ :=
!![1, 0, 0, 0;
0, 2 * c ^ 2 - 1, 2 * c * Real.sqrt (1 - c ^ 2), 0;
0, -(2 * c * Real.sqrt (1 - c ^ 2)), 2 * c ^ 2 - 1, 0;
0, 0, 0, 1]
/-- Eqs. (26), (29), (31): the modified rotation matrix `ℜ̃(φ_G)`, where `σ = (Ω × ν)·e_z`:
`ℜ̃(φ_G) = ½ (1 + sgn σ) ℜ(φ_G) + ½ (1 - sgn σ) ℜ(-φ_G)`, so that it equals `ℜ(φ_G)` when `σ > 0`
(Eq. 26) and `ℜ(-φ_G)` when `σ < 0` (Eq. 29). (Eq. (31) as printed places the factor `½` before
the first term only; see the mission description.) -/
def modRot (σ φ : ℝ) : Matrix (Fin 4) (Fin 4) ℝ :=
(1 / 2 : ℝ) • ((1 + Real.sign σ) • stokesRot φ + (1 - Real.sign σ) • stokesRot (-φ))
/-- Eq. (64): the matrix `T = diag(1, 1, -1, 1)` transforming a Stokes vector defined in the
right-hand frame into the Stokes vector defined in the left-hand frame (Eq. 63). -/
def handT : Matrix (Fin 4) (Fin 4) ℝ :=
Matrix.diagonal ![1, 1, -1, 1]
/-- Eqs. (13), (20): the transport operator `n² d/ds [I/n²]` applied to a Stokes vector `S(s)`
along a ray with refractive index `n(s)`, at ray coordinate `s`. -/
def transportOp (n : ℝ → ℝ) (S : ℝ → Stokes) (s : ℝ) : Stokes :=
(n s ^ 2) • deriv (fun t => (n t ^ 2)⁻¹ • S t) s
/-- Directions of propagation: unit vectors `Ω ∈ ℝ³`. -/
abbrev Dir : Type := ↥(Metric.sphere (0 : EuclideanSpace ℝ (Fin 3)) 1)
/-- The solid-angle measure `dΩ` on the unit sphere (total mass `4π`). -/
def solidAngle : Measure Dir :=
(volume : Measure (EuclideanSpace ℝ (Fin 3))).toSphere
/-- Eqs. (18), (20): the scattering source `(1/4π) ∫_{4π} Z(Ω', Ω) I(Ω') dΩ'`, for the phase matrix
`Z(·, Ω)` of the current direction `Ω` and the Stokes vectors `I(Ω')` of the incident directions at
the current point. -/
def scatSource (Z : Dir → Matrix (Fin 4) (Fin 4) ℝ) (L : Dir → Stokes) : Stokes :=
(1 / (4 * Real.pi)) • ∫ ω, Z ω *ᵥ L ω ∂solidAngle
/-- Eqs. (37), (38): the derivative `dM/ds` of a matrix-valued function of the ray coordinate,
taken entrywise. -/
def matDeriv (M : ℝ → Matrix (Fin 4) (Fin 4) ℝ) (s : ℝ) : Matrix (Fin 4) (Fin 4) ℝ :=
fun i j => deriv (fun t => M t i j) s
/-- Vectors of `ℝ³` in Cartesian (or local orthonormal) components. -/
abbrev Vec3 := Fin 3 → ℝ
/-- The Euclidean length `|v| = √(v·v)` of a vector of `ℝ³`. -/
def vlen (v : Vec3) : ℝ :=
Real.sqrt (v ⬝ᵥ v)
/-- Eq. (46): the curvature `K = |dΩ/ds|` of a ray with unit tangent `Ω(s)`. -/
def rayCurvature (Ω : ℝ → Vec3) (s : ℝ) : ℝ :=
vlen (deriv Ω s)
/-- Fig. 2, Eq. (46): the principal normal `ν = (dΩ/ds)/K` of a ray with unit tangent `Ω(s)`. -/
def frenetNormal (Ω : ℝ → Vec3) (s : ℝ) : Vec3 :=
(rayCurvature Ω s)⁻¹ • deriv Ω s
/-- Fig. 2, Eq. (46): the binormal `b = Ω × ν`, so that `ν, b, Ω` is a right-hand frame. -/
def frenetBinormal (Ω : ℝ → Vec3) (s : ℝ) : Vec3 :=
Ω s ⨯₃ frenetNormal Ω s
/-- Eq. (46): the torsion of the ray in the paper's sign convention, `κ = -b · dν/ds`. -/
def rayTorsion (Ω : ℝ → Vec3) (s : ℝ) : ℝ :=
-(frenetBinormal Ω s ⬝ᵥ deriv (frenetNormal Ω) s)
section Streaming
variable {E : Type*} [NormedAddCommGroup E] [NormedSpace ℝ E]
/-- The partial derivative `∂f/∂qᵢ` of a function of three spatial coordinates `q = (q₀, q₁, q₂)`. -/
def pd (f : Vec3 → E) (i : Fin 3) (q : Vec3) : E :=
deriv (fun r => f (Function.update q i r)) (q i)
/-- Eq. (42) and Figs. 6-8: the components `(μ, η, ξ) = (sin θ cos φ, sin θ sin φ, cos θ)` of the
direction `Ω` in the local orthonormal frame of the coordinate system. -/
def dirVec (θ φ : ℝ) : Vec3 :=
![Real.sin θ * Real.cos φ, Real.sin θ * Real.sin φ, Real.cos θ]
/-- Eq. (42) and Figs. 6-8: the auxiliary vector `s₁ = (-sin φ, cos φ, 0)` in the local frame. -/
def auxS1 (φ : ℝ) : Vec3 :=
![-Real.sin φ, Real.cos φ, 0]
/-- The polar axis of the angles `θ, φ` in the local frame: `k` (Eq. 42), `e_z` (Eq. 49),
`e_ρ` (Eqs. 52, 55); it is the third vector of the local frame in each case. -/
def polarAxis : Vec3 :=
![0, 0, 1]
/-- Eq. (42): the gradient in Cartesian coordinates `q = (x, y, z)`. -/
def cartGrad (f : Vec3 → E) (q : Vec3) : Fin 3 → E :=
fun i => pd f i q
/-- Eq. (49): the gradient in the traditional cylindrical coordinates `q = (ρ, Ψ, z)` of Fig. 7(a),
in the local frame `(e_ρ, e_Ψ, e_z)`: `(∂/∂ρ, ρ⁻¹ ∂/∂Ψ, ∂/∂z)`. -/
def tradCylGrad (f : Vec3 → E) (q : Vec3) : Fin 3 → E :=
![pd f 0 q, (q 0)⁻¹ • pd f 1 q, pd f 2 q]
/-- Eq. (52): the gradient in the new cylindrical coordinates `q = (ρ, Ψ, z)` of Fig. 7(b), in the
local frame `(e_Ψ, e_z, e_ρ)`: `(ρ⁻¹ ∂/∂Ψ, ∂/∂z, ∂/∂ρ)`. -/
def newCylGrad (f : Vec3 → E) (q : Vec3) : Fin 3 → E :=
![(q 0)⁻¹ • pd f 1 q, pd f 2 q, pd f 0 q]
/-- Eq. (55): the gradient in the spherical coordinates `q = (Θ, Ψ, ρ)` of Fig. 8, in the local
frame `(e_Θ, e_Ψ, e_ρ)`: `(ρ⁻¹ ∂/∂Θ, (ρ sin Θ)⁻¹ ∂/∂Ψ, ∂/∂ρ)`. -/
def sphGrad (f : Vec3 → E) (q : Vec3) : Fin 3 → E :=
![(q 2)⁻¹ • pd f 0 q, (q 2 * Real.sin (q 0))⁻¹ • pd f 1 q, pd f 2 q]
/-- `Ω · G` for a vector `G` given by its components in the local frame. -/
def dirDot (θ φ : ℝ) (G : Fin 3 → E) : E :=
∑ i, dirVec θ φ i • G i
end Streaming
/-- `∂I/∂θ` for a field `I(q, θ, φ)` of position and direction angles. -/
def dTheta (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
deriv (fun θ' => F q θ' φ) θ
/-- `∂I/∂φ` for a field `I(q, θ, φ)` of position and direction angles. -/
def dPhi (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
deriv (fun φ' => F q θ φ') φ
/-- Eqs. (42), (44), (49), (50), (52), (53), (55), (56): the angular-redistribution term
`(1/sin θ) {[(ξΩ - e₃)·g] ∂I/∂θ + [s₁·g] ∂I/∂φ}`, where `g` holds the local components of `∇n/n`
and `e₃` is the polar axis. -/
def angularStream (g : Vec3) (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
(Real.sin θ)⁻¹ • (((Real.cos θ • dirVec θ φ - polarAxis) ⬝ᵥ g) • dTheta F q θ φ +
(auxS1 φ ⬝ᵥ g) • dPhi F q θ φ)
/-- Eqs. (45), (48), (51), (54), (57): the angular term in conservative form,
`(1/sin θ) {∂/∂θ [((ξΩ - e₃)·g) I] + ∂/∂φ [(s₁·g) I]}`, with `g` the local components of `∇n/n`. -/
def angularCons (g : Vec3) (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
(Real.sin θ)⁻¹ •
(deriv (fun θ' => ((Real.cos θ' • dirVec θ' φ - polarAxis) ⬝ᵥ g) • F q θ' φ) θ +
deriv (fun φ' => (auxS1 φ' ⬝ᵥ g) • F q θ φ') φ)
/-- Eq. (42) (quoted from Ref. [26]): the Eulerian streaming operator `∂/∂s` in Cartesian
coordinates, `Ω·∇ + (1/sin θ){[(ξΩ - k)·∇n/n] ∂/∂θ + [s₁·∇n/n] ∂/∂φ}`. -/
def cartStream (n : Vec3 → ℝ) (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
dirDot θ φ (cartGrad (fun y => F y θ φ) q) + angularStream ((n q)⁻¹ • cartGrad n q) F q θ φ
/-- Eq. (49) (quoted from Ref. [29]): the Eulerian streaming operator in the traditional cylindrical
coordinates, `Ω·∇ - (η/ρ) ∂/∂φ + (1/sin θ){[(ξΩ - e_z)·∇n/n] ∂/∂θ + [s₁·∇n/n] ∂/∂φ}`. -/
def tradCylStream (n : Vec3 → ℝ) (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
dirDot θ φ (tradCylGrad (fun y => F y θ φ) q) -
(Real.sin θ * Real.sin φ / q 0) • dPhi F q θ φ +
angularStream ((n q)⁻¹ • tradCylGrad n q) F q θ φ
/-- Eq. (52) (quoted from Ref. [30]): the Eulerian streaming operator in the new cylindrical
coordinates, `Ω·∇ - μ (cos φ/ρ) ∂/∂θ + ξ (sin φ cos φ/ρ) ∂/∂φ
+ (1/sin θ){[(ξΩ - e_ρ)·∇n/n] ∂/∂θ + [s₁·∇n/n] ∂/∂φ}`. -/
def newCylStream (n : Vec3 → ℝ) (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
dirDot θ φ (newCylGrad (fun y => F y θ φ) q) -
(Real.sin θ * Real.cos φ * Real.cos φ / q 0) • dTheta F q θ φ +
(Real.cos θ * Real.sin φ * Real.cos φ / q 0) • dPhi F q θ φ +
angularStream ((n q)⁻¹ • newCylGrad n q) F q θ φ
/-- Eq. (55) (quoted from Ref. [29]): the Eulerian streaming operator in the spherical coordinates,
`Ω·∇ - (sin θ/ρ) ∂/∂θ - (η cot Θ/ρ) ∂/∂φ + (1/sin θ){[(ξΩ - e_ρ)·∇n/n] ∂/∂θ + [s₁·∇n/n] ∂/∂φ}`. -/
def sphStream (n : Vec3 → ℝ) (F : Vec3 → ℝ → ℝ → Stokes) (q : Vec3) (θ φ : ℝ) : Stokes :=
dirDot θ φ (sphGrad (fun y => F y θ φ) q) -
(Real.sin θ / q 2) • dTheta F q θ φ -
(Real.sin θ * Real.sin φ * Real.cot (q 0) / q 2) • dPhi F q θ φ +
angularStream ((n q)⁻¹ • sphGrad n q) F q θ φ
end Arxiv1110_5134
Read-back
What the Lean code literally says, in plain math · claude-opus-5-5
Stokes vectors. A Stokes vector is any element of . Its components are indexed (conventionally ). No constraint is imposed: the components need not satisfy or .
Stokes vector of an ellipse. For arbitrary real numbers , with no sign or range restriction (in particular may be negative or zero), the vector is defined as
Rytov matrix. For any real , is the real matrix whose only nonzero entries are in row 2, column 3, and in row 3, column 2 (counting rows and columns from 1):
These are the entries coupling the and components. If , this is the zero matrix.
Stokes rotation matrix. For any real angle :
Rotation matrix in terms of a cosine. For any real number , with no restriction to :
Here denotes the real square root with the convention for . So for the off-diagonal entries are and the middle diagonal entries are . For , the square root is nonnegative, so , with angle in . Nothing in the definition ties to any angle.
Modified rotation matrix. For any reals and , with and :
This takes three values depending on the sign of :
- : it equals .
- : it equals .
- : it equals , which is not a rotation in general.
Here is just a free real parameter; the definition contains no vectors , or .
Handedness matrix. is the constant diagonal matrix
Transport operator. Given an arbitrary function , an arbitrary curve and a point , define
Two conventions apply:
- is taken to be wherever .
- If is not differentiable at , the derivative is taken to be the zero vector, so the operator returns .
No positivity, smoothness or differentiability of or is assumed. If , the result is .
Directions. A direction is a point of the unit sphere , with the Euclidean norm.
Solid-angle measure. The measure on is induced from Lebesgue measure on by the cone construction:
This is the standard surface measure, with total mass .
Scattering source. Given an arbitrary map and an arbitrary map , define
where is a matrix-vector product. The integral is the Bochner integral, which is defined to be if is not integrable. The matrix depends only on the integration variable ; no "current direction" appears as an argument.
Entrywise matrix derivative. For any and any , is the matrix whose entry is the derivative at of . Each entry is taken to be where the corresponding entry function is not differentiable at .
Vectors in . Elements of are plain coordinate triples . Their length is , the Euclidean norm.
Curvature of a ray. For an arbitrary function and a point , the curvature is
is not required to have unit length or to be differentiable. If is not differentiable at , then is taken to be , so .
Principal normal. The normal is
with when . In that case . Otherwise is a unit vector.
Binormal. The binormal is
the cross product in . It is a unit vector only when is a unit vector orthogonal to the unit vector ; neither condition is assumed.
Torsion of a ray. The torsion is
where is the derivative at of the function defined above. That derivative is taken to be if is not differentiable at , giving . Note the explicit minus sign.
Partial derivatives. For a normed real vector space , a function , an index and a point , is the derivative at of . It is taken to be if that one-variable function is not differentiable there.
Direction components. For real :
Auxiliary vector. For real :
Polar axis. The polar axis is the constant vector .
These three are bare coordinate triples. No frame, basis or coordinate system is attached to them.
Gradient formulas. For and , with no restriction on , four triples in are defined. Throughout, when .
- Cartesian:
- Traditional cylindrical:
- New cylindrical:
- Spherical:
For example, at the second component of is . In the spherical formula, the second component is whenever or . Also, is not required to be positive, and is not required to be nonzero.
Direction dot product. For :
Angular partial derivatives. For a field , written :
- is the derivative of at .
- is the derivative of at .
Each is if the corresponding function is not differentiable there.
Angular redistribution term. For a fixed vector , the field , and :
Here when , so the whole term vanishes at .
Conservative angular term. With the same inputs:
The same conventions apply: nondifferentiable means a derivative, and when . The vector is held fixed and does not vary with the angles.
Streaming operators. For an arbitrary function (not assumed positive or differentiable), a field , and , write for the chosen gradient formula applied to with the angles held fixed. Each operator uses the matching gradient formula for , and the convention applies, so where . Division by yields throughout.
- Cartesian:
- Traditional cylindrical:
- New cylindrical:
- Spherical:
Here , with value when .
In all four operators, and every term is evaluated at . The coordinates are an unconstrained real triple: the definitions contain no geometric change of variables, only these explicit formulas.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.