import NavierStokes.HarmonicResidual import NavierStokes.WaveInteractionBounds /-! # Actual harmonic residual changes under a mean increment The wave and its pressure are held fixed. Every coefficient below belongs to the actual differential residual in `HarmonicResidual`; excluded errors are kept as separate additive differences. -/ noncomputable section namespace NavierStokes.HarmonicMeanInteraction open Set Filter Function HarmonicCalculus HarmonicFields WeightedClasses open WaveInteractionBounds open scoped Topology ContDiff BigOperators ComplexConjugate variable {D : Type} [NormedAddCommGroup D] [NormedSpace ℝ D] omit [NormedAddCommGroup D] [NormedSpace ℝ D] in @[simp] theorem coeff_add (a b : Coefficients D) (j : ℤ) (x : D) : (a + b) j x = a j x + b j x := rfl omit [NormedAddCommGroup D] [NormedSpace ℝ D] in @[simp] theorem coeff_sub (a b : Coefficients D) (j : ℤ) (x : D) : (a - b) j x = a j x - b j x := rfl omit [NormedAddCommGroup D] [NormedSpace ℝ D] in @[simp] theorem coeff_neg (a : Coefficients D) (j : ℤ) (x : D) : (-a) j x = -a j x := rfl omit [NormedAddCommGroup D] [NormedSpace ℝ D] in @[simp] theorem coeff_zero (j : ℤ) (x : D) : (0 : Coefficients D) j x = 0 := rfl omit [NormedAddCommGroup D] [NormedSpace ℝ D] in @[simp] theorem constant_mul (f : D → ℂ) (a : Coefficients D) (j : ℤ) (x : D) : (constantCoefficient f * a) j x = f x * a j x := by rw [constantCoefficient, AddMonoidAlgebra.coeff_single_zero_mul] rfl omit [NormedAddCommGroup D] [NormedSpace ℝ D] in @[simp] theorem mul_constant (a : Coefficients D) (f : D → ℂ) (j : ℤ) (x : D) : (a * constantCoefficient f) j x = a j x * f x := by rw [constantCoefficient, AddMonoidAlgebra.coeff_mul_single_zero] rfl omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem constant_mul_constant (f g : D → ℂ) : constantCoefficient f * constantCoefficient g = constantCoefficient (fun x => f x * g x) := by ext j x rw [constant_mul] by_cases hj : j = 0 · simp [hj, constantCoefficient] · simp [constantCoefficient, hj] theorem differentiate_constant (V : D → D) (k : ℝ) (Φ : D → ℝ) (f : D → ℂ) : differentiate V k Φ (constantCoefficient f) = constantCoefficient (along V f) := by ext j x by_cases hj : j = 0 · subst j simp [differentiate_apply, derivativeCoefficient, constantCoefficient, phaseFactor] · have hz : (constantCoefficient f : Coefficients D) j = 0 := by simp [constantCoefficient, hj] simp [differentiate_apply, derivativeCoefficient_zero, constantCoefficient, hj] omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem angularDifferentiate_constant (kp : ℤ) (f : D → ℂ) : angularDifferentiate kp (constantCoefficient f) = 0 := by ext j x by_cases hj : j = 0 · subst j simp [angularDifferentiate_apply] · simp [angularDifferentiate_apply, constantCoefficient, hj] omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem rotate_constant (m : D → ComplexVector) (i : Fin 3) : HarmonicResidual.rotate (HarmonicResidual.constantVector m) i = constantCoefficient (fun x => angularGenerator (m x) i) := by ext j x fin_cases i <;> simp [HarmonicResidual.rotate, HarmonicResidual.constantVector, angularGenerator, constantCoefficient] <;> split_ifs <;> simp omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem rotate_apply (a : HarmonicResidual.VectorCoefficients D) (j : ℤ) (x : D) (i : Fin 3) : HarmonicResidual.rotate a i j x = angularGenerator (fun l => a l j x) i := by fin_cases i <;> rfl theorem transport_constant_left (g : HarmonicResidual.Frame D) (k : ℝ) (Φ : D → ℝ) (kp : ℤ) (m : D → ComplexVector) (a : HarmonicResidual.VectorCoefficients D) (j : ℤ) (x : D) (i : Fin 3) : HarmonicResidual.transport g k Φ kp (HarmonicResidual.constantVector m) a i j x = m x 0 * derivativeCoefficient g.radial k Φ j (a i j) x + (m x 1 / (g.radius x : ℂ)) * ((((j * kp : ℤ) : ℂ) * Complex.I) * a i j x + angularGenerator (fun l => a l j x) i) + m x 2 * derivativeCoefficient g.axial k Φ j (a i j) x := by simp only [HarmonicResidual.transport, HarmonicResidual.constantVector, coeff_add, constant_mul, constant_mul_constant, angularDifferentiate_apply, differentiate_apply, rotate_apply, div_eq_mul_inv] theorem transport_constant_right (g : HarmonicResidual.Frame D) (k : ℝ) (Φ : D → ℝ) (kp : ℤ) (a : HarmonicResidual.VectorCoefficients D) (m : D → ComplexVector) (j : ℤ) (x : D) (i : Fin 3) : HarmonicResidual.transport g k Φ kp a (HarmonicResidual.constantVector m) i j x = a 0 j x * along g.radial (fun y => m y i) x + (a 1 j x / (g.radius x : ℂ)) * angularGenerator (m x) i + a 2 j x * along g.axial (fun y => m y i) x := by simp only [HarmonicResidual.transport, HarmonicResidual.constantVector, coeff_add, differentiate_constant, mul_constant, angularDifferentiate_constant, zero_add, rotate_constant, div_eq_mul_inv] /-- The two actual cross-advections at coefficient level, before any zero-mode deletion. -/ noncomputable def crossCoefficients (g : HarmonicResidual.Frame D) (k : ℝ) (Φ : D → ℝ) (kp : ℤ) (m : D → ComplexVector) (a : HarmonicResidual.VectorCoefficients D) : HarmonicResidual.VectorCoefficients D := fun i => HarmonicResidual.transport g k Φ kp (HarmonicResidual.constantVector m) a i + HarmonicResidual.transport g k Φ kp a (HarmonicResidual.constantVector m) i theorem nonlinear_mean_difference (g : HarmonicResidual.Frame D) (k : ℝ) (Φ : D → ℝ) (kp : ℤ) (B m : D → ComplexVector) (a : HarmonicResidual.VectorCoefficients D) (p : Coefficients D) {x : D} (hB : ∀ i, DifferentiableAt ℝ (fun y => B y i) x) (hm : ∀ i, DifferentiableAt ℝ (fun y => m y i) x) (j : ℤ) (i : Fin 3) : HarmonicResidual.nonlinearResidual g k Φ kp (HarmonicResidual.constantVector (B + m)) a p i j x - HarmonicResidual.nonlinearResidual g k Φ kp (HarmonicResidual.constantVector B) a p i j x = crossCoefficients g k Φ kp m a i j x := by simp only [HarmonicResidual.nonlinearResidual, HarmonicResidual.linearResidual, crossCoefficients, coeff_add, coeff_sub, transport_constant_left, transport_constant_right, Pi.add_apply, along_add _ (hB i) (hm i), HarmonicResidual.Actual.angularGenerator_add] ring omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem realCoefficients_sub (a b : Coefficients D) : HarmonicResidual.realCoefficients (a - b) = HarmonicResidual.realCoefficients a - HarmonicResidual.realCoefficients b := by ext j x simp only [HarmonicResidual.realCoefficients_apply, coeff_sub, map_sub] ring omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem realCoefficients_add (a b : Coefficients D) : HarmonicResidual.realCoefficients (a + b) = HarmonicResidual.realCoefficients a + HarmonicResidual.realCoefficients b := by ext j x simp only [HarmonicResidual.realCoefficients_apply, coeff_add, map_add] ring noncomputable def tripleField (h : MeanIncrementBounds.Triple D) (n : ℕ) (x : D) : ComplexVector := ![(h.radial n x : ℂ), (h.angular n x : ℂ), (h.axial n x : ℂ)] omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem stateMean_updated (s₀ s₁ : CorrectionState.State D) (h : MeanIncrementBounds.Triple D) (he : s₁.mean = MeanIncrementBounds.updated s₀.mean h) (n : ℕ) : HarmonicResidual.stateMean s₁ n = HarmonicResidual.stateMean s₀ n + tripleField h n := by ext x i fin_cases i <;> simp [HarmonicResidual.stateMean, tripleField, he, MeanIncrementBounds.updated] noncomputable def blockAmplitude (b : CorrectionState.HarmonicBlock D) (n : ℕ) : HarmonicResidual.VectorCoefficients D := fun i => HarmonicResidual.realCoefficients (b.velocity n i) noncomputable def meanCross (c : CorrectionState.Context D) (h : MeanIncrementBounds.Triple D) (b : CorrectionState.HarmonicBlock D) (n : ℕ) : HarmonicResidual.VectorCoefficients D := crossCoefficients (HarmonicResidual.contextFrame c n) (b.frequency n) (b.phase n) (b.angularFrequency n) (tripleField h n) (blockAmplitude b n) /-- General additive error differences are retained, including their zero modes. -/ theorem residualCoefficients_mean_update (c : CorrectionState.Context D) (s₀ s₁ : CorrectionState.State D) (h : MeanIncrementBounds.Triple D) (he : s₁.mean = MeanIncrementBounds.updated s₀.mean h) (b : CorrectionState.HarmonicBlock D) (G₀ G₁ A₀ A₁ : HarmonicResidual.BlockCoefficients D) (n : ℕ) {x : D} (hB : ∀ i, DifferentiableAt ℝ (fun y => HarmonicResidual.contextBase c n y i) x) (hM : ∀ i, DifferentiableAt ℝ (fun y => HarmonicResidual.stateMean s₀ n y i) x) (hh : ∀ i, DifferentiableAt ℝ (fun y => tripleField h n y i) x) (j : ℤ) (i : Fin 3) : (HarmonicResidual.ofBlock b G₁ A₁ n).residualCoefficients (HarmonicResidual.contextFrame c n) (HarmonicResidual.contextBase c n) (HarmonicResidual.stateMean s₁ n) i j x - (HarmonicResidual.ofBlock b G₀ A₀ n).residualCoefficients (HarmonicResidual.contextFrame c n) (HarmonicResidual.contextBase c n) (HarmonicResidual.stateMean s₀ n) i j x = HarmonicResidual.realCoefficients (meanCross c h b n i - (G₁ n i - G₀ n i) - (A₁ n i - A₀ n i)) j x := by have hsum : HarmonicResidual.contextBase c n + HarmonicResidual.stateMean s₁ n = (HarmonicResidual.contextBase c n + HarmonicResidual.stateMean s₀ n) + tripleField h n := by rw [stateMean_updated s₀ s₁ h he n] abel have hdiff (l : ℤ) := nonlinear_mean_difference (HarmonicResidual.contextFrame c n) (b.frequency n) (b.phase n) (b.angularFrequency n) (HarmonicResidual.contextBase c n + HarmonicResidual.stateMean s₀ n) (tripleField h n) (blockAmplitude b n) (HarmonicResidual.realCoefficients (b.pressure n)) (fun t => (hB t).add (hM t)) hh l i let N₀ := HarmonicResidual.nonlinearResidual (HarmonicResidual.contextFrame c n) (b.frequency n) (b.phase n) (b.angularFrequency n) (HarmonicResidual.constantVector (HarmonicResidual.contextBase c n + HarmonicResidual.stateMean s₀ n)) (blockAmplitude b n) (HarmonicResidual.realCoefficients (b.pressure n)) i let N₁ := HarmonicResidual.nonlinearResidual (HarmonicResidual.contextFrame c n) (b.frequency n) (b.phase n) (b.angularFrequency n) (HarmonicResidual.constantVector ((HarmonicResidual.contextBase c n + HarmonicResidual.stateMean s₀ n) + tripleField h n)) (blockAmplitude b n) (HarmonicResidual.realCoefficients (b.pressure n)) i simp only [HarmonicResidual.LabelData.residualCoefficients, hsum] change HarmonicResidual.realCoefficients (N₁ - G₁ n i - A₁ n i) j x - HarmonicResidual.realCoefficients (N₀ - G₀ n i - A₀ n i) j x = _ rw [← coeff_sub, ← realCoefficients_sub] simp only [HarmonicResidual.realCoefficients_apply, coeff_sub] have hdj := hdiff j have hdn := hdiff (-j) change N₁ j x - N₀ j x = meanCross c h b n i j x at hdj change N₁ (-j) x - N₀ (-j) x = meanCross c h b n i (-j) x at hdn rw [← hdj, ← hdn] simp only [map_sub] ring /-! ## Bounds on the original coefficient domain -/ /-- The slow coefficient geometry has no artificial angular coordinate. The actual separate angular carrier is accounted for explicitly below. -/ noncomputable def slowGeometry {s : StripData D} {κ : ℝ} (c : CorrectionState.Context D) (ho : MeanIncrementBounds.OperatorBounds s c.operators κ) (hR : ∀ x ∈ s.domain, 0 < c.operators.radius x) : Geometry s κ where radius := fun _ => c.operators.radius radial := fun n => (HarmonicResidual.contextFrame c n).radial angular := fun _ _ => 0 axial := fun n => (HarmonicResidual.contextFrame c n).axial radius_pos := fun _ x hx => hR x hx radial_class := by convert! graph_vector_class ho.kappa_nonneg ho.radialFrequency ho.radialProfile c.operators.eR c.operators.vR using 1 ext n x simp [HarmonicResidual.contextFrame, smul_smul] axial_class := by simpa only [HarmonicResidual.contextFrame, ho.epsilon_eq] using axial_vector_class s c.operators.eZ inverse_radius_class := ho.invRadius noncomputable def slowNormal {s : StripData D} {κ : ℝ} (c : CorrectionState.Context D) (ho : MeanIncrementBounds.OperatorBounds s c.operators κ) (hR : ∀ x ∈ s.domain, 0 < c.operators.radius x) (Φ : ℕ → D → ℝ) (n : ℕ) (x : D) : EuclideanSpace ℝ (Fin 3) := phaseNormal ((slowGeometry c ho hR).radius n) ((slowGeometry c ho hR).radial n) ((slowGeometry c ho hR).angular n) ((slowGeometry c ho hR).axial n) (Φ n) x theorem tripleField_bound {s : StripData D} {H : ℝ} {h : MeanIncrementBounds.Triple D} (hh : MeanIncrementBounds.IncrementBounds s H h) : MeanVector s H (tripleField h) := by refine ⟨?_, ?_, ?_⟩ · exact hh.radial.map Complex.ofRealCLM · exact hh.angular.map Complex.ofRealCLM · exact hh.axial.map Complex.ofRealCLM theorem realCoefficient_class {s : StripData D} {P : ℕ → D → ℝ} {α : ℝ} (a : ℕ → Coefficients D) (j : ℤ) (ha : WaveClass s P α (fun n x => a n j x)) (han : WaveClass s P α (fun n x => a n (-j) x)) : WaveClass s P α (fun n x => HarmonicResidual.realCoefficients (a n) j x) := by apply class_congr (class_const_cmul (ha.add (class_conj han)) ((2 : ℂ)⁻¹)) intro n x _ exact (HarmonicResidual.realCoefficients_apply (a n) j x).symm theorem blockAmplitude_class {s : StripData D} {P : ℕ → D → ℝ} {α : ℝ} {b : CorrectionState.HarmonicBlock D} (hb : b.WaveBounds s P α) {j : ℤ} (hj : j ≠ 0) : WaveVector s P α (fun n x i => blockAmplitude b n i j x) := by intro i exact realCoefficient_class (fun n => b.velocity n i) j (hb i j hj) (hb i (-j) (neg_ne_zero.mpr hj)) /-- The separate angular phase term has the same carrier loss as the slow phase term. -/ noncomputable def angularCarrierTerm (c : CorrectionState.Context D) (b : CorrectionState.HarmonicBlock D) (h : MeanIncrementBounds.Triple D) (j : ℤ) (n : ℕ) (x : D) (i : Fin 3) : ℂ := phaseFactor ((b.angularFrequency n : ℝ) * (j : ℝ)) * (tripleField h n x 1 / (c.operators.radius x : ℂ)) * blockAmplitude b n i j x theorem meanCross_eq {s : StripData D} {κ : ℝ} (c : CorrectionState.Context D) (ho : MeanIncrementBounds.OperatorBounds s c.operators κ) (hR : ∀ x ∈ s.domain, 0 < c.operators.radius x) (h : MeanIncrementBounds.Triple D) (b : CorrectionState.HarmonicBlock D) (j : ℤ) (n : ℕ) (x : D) (i : Fin 3) : meanCross c h b n i j x = waveMeanCoefficient (slowGeometry c ho hR) b.phase (fun n => b.frequency n * (j : ℝ)) (tripleField h) (fun n x i => blockAmplitude b n i j x) n x i + angularCarrierTerm c b h j n x i := by simp only [meanCross, crossCoefficients, coeff_add, transport_constant_left, transport_constant_right, derivativeCoefficient, waveMeanCoefficient, strippedTransport, normalDot, phaseNormal, slowGeometry, HarmonicResidual.contextFrame, angularCarrierTerm, phaseFactor, along, map_zero, zero_mul, Complex.ofReal_mul, Complex.ofReal_intCast, Int.cast_mul, div_eq_mul_inv] simp only [ Matrix.cons_val_zero, Matrix.cons_val_one, Matrix.cons_val_two, Matrix.tail_cons, Matrix.head_cons, Complex.ofReal_zero, zero_mul, add_zero] ring /-! ## The actual output residual blocks -/ omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem nonconstant_apply_of_ne (a : Coefficients D) {j : ℤ} (hj : j ≠ 0) (x : D) : HarmonicResidual.nonconstant a j x = a j x := by change a.coeff.erase 0 j x = a.coeff j x rw [Finsupp.erase_ne hj] theorem residualBlock_mean_update (c : CorrectionState.Context D) (s₀ s₁ : CorrectionState.State D) (h : MeanIncrementBounds.Triple D) (he : s₁.mean = MeanIncrementBounds.updated s₀.mean h) (b : CorrectionState.HarmonicBlock D) (G₀ G₁ A₀ A₁ : HarmonicResidual.BlockCoefficients D) (n : ℕ) {x : D} (hB : ∀ i, DifferentiableAt ℝ (fun y => HarmonicResidual.contextBase c n y i) x) (hM : ∀ i, DifferentiableAt ℝ (fun y => HarmonicResidual.stateMean s₀ n y i) x) (hh : ∀ i, DifferentiableAt ℝ (fun y => tripleField h n y i) x) (j : ℤ) (i : Fin 3) : (HarmonicResidual.residualBlock c s₁ b G₁ A₁).velocity n i j x - (HarmonicResidual.residualBlock c s₀ b G₀ A₀).velocity n i j x = HarmonicResidual.nonconstant (HarmonicResidual.realCoefficients (meanCross c h b n i - (G₁ n i - G₀ n i) - (A₁ n i - A₀ n i))) j x := by by_cases hj : j = 0 · subst j simp [HarmonicResidual.residualBlock_zero_mode, HarmonicResidual.nonconstant] · change HarmonicResidual.nonconstant _ j x - HarmonicResidual.nonconstant _ j x = _ simp only [nonconstant_apply_of_ne _ hj] exact residualCoefficients_mean_update c s₀ s₁ h he b G₀ G₁ A₀ A₁ n hB hM hh j i omit [NormedAddCommGroup D] [NormedSpace ℝ D] in theorem band_zero_coefficient {a : Coefficients D} (ha : BandLimited a 0) {j : ℤ} (hj : j ≠ 0) : a j = 0 := by have hnj : j ∉ a.support := by intro hmem exact hj (Int.natAbs_eq_zero.mp (Nat.eq_zero_of_le_zero (ha j hmem))) exact Finsupp.notMem_support_iff.mp hnj /-- An axisymmetric alias change has no effect on nonzero harmonics. The Gaussian field is unchanged, so it cancels without a size assumption. -/ theorem residualBlock_axisymmetric_alias_update (c : CorrectionState.Context D) (s₀ s₁ : CorrectionState.State D) (h : MeanIncrementBounds.Triple D) (he : s₁.mean = MeanIncrementBounds.updated s₀.mean h) (b : CorrectionState.HarmonicBlock D) (G A₀ A₁ : HarmonicResidual.BlockCoefficients D) (hA : ∀ n i, BandLimited (A₁ n i - A₀ n i) 0) (n : ℕ) {x : D} (hB : ∀ i, DifferentiableAt ℝ (fun y => HarmonicResidual.contextBase c n y i) x) (hM : ∀ i, DifferentiableAt ℝ (fun y => HarmonicResidual.stateMean s₀ n y i) x) (hh : ∀ i, DifferentiableAt ℝ (fun y => tripleField h n y i) x) {j : ℤ} (hj : j ≠ 0) (i : Fin 3) : (HarmonicResidual.residualBlock c s₁ b G A₁).velocity n i j x - (HarmonicResidual.residualBlock c s₀ b G A₀).velocity n i j x = HarmonicResidual.realCoefficients (meanCross c h b n i) j x := by have hzj := congrArg (fun f : D → ℂ => f x) (band_zero_coefficient (hA n i) hj) have hzn := congrArg (fun f : D → ℂ => f x) (band_zero_coefficient (hA n i) (neg_ne_zero.mpr hj)) change A₁ n i j x - A₀ n i j x = 0 at hzj change A₁ n i (-j) x - A₀ n i (-j) x = 0 at hzn rw [residualBlock_mean_update c s₀ s₁ h he b G G A₀ A₁ n hB hM hh j i, nonconstant_apply_of_ne _ hj] simp only [sub_self, sub_zero, HarmonicResidual.realCoefficients_apply, coeff_sub, hzj, hzn] theorem tripleField_smooth {U : Set D} {h : MeanIncrementBounds.Triple D} (hh : MeanIncrementBounds.SmoothTriple U h) (n : ℕ) (i : Fin 3) : ContDiffOn ℝ ∞ (fun x => tripleField h n x i) U := by fin_cases i · exact Complex.ofRealCLM.contDiff.comp_contDiffOn (hh.radial n) · exact Complex.ofRealCLM.contDiff.comp_contDiffOn (hh.angular n) · exact Complex.ofRealCLM.contDiff.comp_contDiffOn (hh.axial n) /-! ## Frequency support and physical cross-advection -/ end NavierStokes.HarmonicMeanInteraction