Imports
/- Copyright (c) 2025 Tomas Skrivan. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Tomas Skrivan -/ module public import Mathlib.LinearAlgebra.Trace public import Physlib.Mathematics.Calculus.AdjFDeriv public import Physlib.SpaceAndTime.Space.Derivatives.Div

Divergence

In this module we define and create an API around the divergence of a map f : E β†’ E where E is a normed space over a field π•œ.

@[expose] public section@[simp] lemma divergence_zero : divergence π•œ (fun _ : E => 0) = fun _ => 0 := π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ E⊒ (divergence π•œ fun x => 0) = fun x => 0 π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ E⊒ (fun x => (LinearMap.trace π•œ E) ↑(fderiv π•œ (fun x => 0) x)) = fun x => 0 All goals completed! πŸ™π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Es:Finset Eb:Basis (β†₯s) π•œ Ef:E β†’ Ex:E⊒ ((LinearMap.toMatrix b b) ↑(fderiv π•œ f x)).trace = βˆ‘ i, (b.repr ((fderiv π•œ f x) (b i))) i π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Es:Finset Eb:Basis (β†₯s) π•œ Ef:E β†’ Ex:E⊒ βˆ‘ x_1, (b.repr (↑(fderiv π•œ f x) (b x_1))) x_1 = βˆ‘ i, (b.repr ((fderiv π•œ f x) (b i))) i All goals completed! πŸ™π•œ:Type u_1inst✝³:RCLike π•œE:Type u_2inst✝²:NormedAddCommGroup Einst✝¹:NormedSpace π•œ EΞΉ:Type u_4inst✝:Fintype ΞΉb:Basis ΞΉ π•œ Ef:E β†’ Es:Finset E := Finset.map { toFun := ⇑b, inj' := β‹― } Finset.univf':ΞΉ β†’ β†₯s := fun i => ⟨b i, β‹―βŸ©h:Function.Injective f'h':Function.Surjective f'e:ΞΉ ≃ β†₯s := Equiv.ofBijective f' β‹―b':Basis (β†₯s) π•œ E := b.reindex ex:E⊒ βˆ‘ i, (b'.repr ((fderiv π•œ f x) (b' i))) i = βˆ‘ i, (b.repr ((fderiv π•œ f x) (b (e.symm i)))) (e.symm i) All goals completed! πŸ™d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ ((fderiv ℝ f x) (Space.basis i)).val i = (fderiv ℝ (⇑(Space.coordCLM i)) (f x) ∘SL fderiv ℝ f x) (Space.basis i)d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ DifferentiableAt ℝ (⇑(Space.coordCLM i)) (f x)d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ DifferentiableAt ℝ f x d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ DifferentiableAt ℝ (⇑(Space.coordCLM i)) (f x)d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ DifferentiableAt ℝ f x d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ DifferentiableAt ℝ (⇑(Space.coordCLM i)) (f x) All goals completed! πŸ™ d:β„•f:Space d β†’ Space dh:Differentiable ℝ fb:Basis (Fin d) ℝ (Space d) := Space.basis.toBasisx:Space di:Fin dh1:fderiv ℝ (fun x => (f x).val i) x = fderiv ℝ (⇑(Space.coordCLM i) ∘ f) x⊒ DifferentiableAt ℝ f x All goals completed! πŸ™π•œ:Type u_1inst✝⁢:RCLike π•œE:Type u_2inst✝⁡:NormedAddCommGroup Einst✝⁴:NormedSpace π•œ EF:Type u_3inst✝³:NormedAddCommGroup Finst✝²:NormedSpace π•œ Finst✝¹:FiniteDimensional π•œ Einst✝:FiniteDimensional π•œ Ff:E Γ— F β†’ Eg:E Γ— F β†’ Fxy:E Γ— Fhf:DifferentiableAt π•œ f xyhg:DifferentiableAt π•œ g xys:Set EbX:Basis (↑s) π•œ Ethis✝:Fintype ↑ssY:Set FbY:Basis (↑sY) π•œ Fthis:Fintype ↑sYbXY:Basis (↑s βŠ• ↑sY) π•œ (E Γ— F) := bX.prod bY⊒ (fun x => βˆ‘ i, (bXY.repr ((fderiv π•œ (fun xy => (f xy, g xy)) x) (bXY i))) i) xy = (fun x => βˆ‘ i, (bX.repr ((fderiv π•œ (fun x' => f (x', xy.2)) x) (bX i))) i) xy.1 + (fun x => βˆ‘ i, (bY.repr ((fderiv π•œ (fun y' => g (xy.1, y')) x) (bY i))) i) xy.2 All goals completed! πŸ™lemma divergence_add {f g : E β†’ E} {x : E} (hf : DifferentiableAt π•œ f x) (hg : DifferentiableAt π•œ g x) : divergence π•œ (fun x => f x + g x) x = divergence π•œ f x + divergence π•œ g x := π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Eg:E β†’ Ex:Ehf:DifferentiableAt π•œ f xhg:DifferentiableAt π•œ g x⊒ divergence π•œ (fun x => f x + g x) x = divergence π•œ f x + divergence π•œ g x π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Eg:E β†’ Ex:Ehf:DifferentiableAt π•œ f xhg:DifferentiableAt π•œ g x⊒ (LinearMap.trace π•œ E) ↑(fderiv π•œ (fun x => f x + g x) x) = (LinearMap.trace π•œ E) ↑(fderiv π•œ f x) + (LinearMap.trace π•œ E) ↑(fderiv π•œ g x) All goals completed! πŸ™lemma divergence_neg {f : E β†’ E} {x : E} : divergence π•œ (fun x => -f x) x = -divergence π•œ f x := π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Ex:E⊒ divergence π•œ (fun x => -f x) x = -divergence π•œ f x π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Ex:E⊒ (LinearMap.trace π•œ E) ↑(fderiv π•œ (fun x => -f x) x) = -(LinearMap.trace π•œ E) ↑(fderiv π•œ f x) All goals completed! πŸ™lemma divergence_sub {f g : E β†’ E} {x : E} (hf : DifferentiableAt π•œ f x) (hg : DifferentiableAt π•œ g x) : divergence π•œ (fun x => f x - g x) x = divergence π•œ f x - divergence π•œ g x := π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Eg:E β†’ Ex:Ehf:DifferentiableAt π•œ f xhg:DifferentiableAt π•œ g x⊒ divergence π•œ (fun x => f x - g x) x = divergence π•œ f x - divergence π•œ g x π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Eg:E β†’ Ex:Ehf:DifferentiableAt π•œ f xhg:DifferentiableAt π•œ g x⊒ (LinearMap.trace π•œ E) ↑(fderiv π•œ (fun x => f x - g x) x) = (LinearMap.trace π•œ E) ↑(fderiv π•œ f x) - (LinearMap.trace π•œ E) ↑(fderiv π•œ g x) All goals completed! πŸ™lemma divergence_const_smul {f : E β†’ E} {x : E} {c : π•œ} (hf : DifferentiableAt π•œ f x) : divergence π•œ (fun x => c β€’ f x) x = c * divergence π•œ f x := π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Ex:Ec:π•œhf:DifferentiableAt π•œ f x⊒ divergence π•œ (fun x => c β€’ f x) x = c * divergence π•œ f x π•œ:Type u_1inst✝²:RCLike π•œE:Type u_2inst✝¹:NormedAddCommGroup Einst✝:NormedSpace π•œ Ef:E β†’ Ex:Ec:π•œhf:DifferentiableAt π•œ f x⊒ (LinearMap.trace π•œ E) ↑(fderiv π•œ (fun x => c β€’ f x) x) = c * (LinearMap.trace π•œ E) ↑(fderiv π•œ f x) All goals completed! πŸ™