Imports
/- Copyright (c) 2025 Joseph Tooby-Smith. All rights reserved. Released under Apache 2.0 license as described in the file LICENSE. Authors: Joseph Tooby-Smith -/ module public import Physlib.Electromagnetism.Dynamics.CurrentDensity public import Physlib.Electromagnetism.Dynamics.KineticTerm public import Physlib.Relativity.Tensors.RealTensor.Vector.MinkowskiProduct

The Lagrangian in electromagnetism

i. Overview

In this module we define the Lagrangian density for the electromagnetic field in presence of a current density. We prove properties of this lagrangian density, and find it's variational gradient.

The lagrangian density is given by L = -1/(4 μ₀) F_{μν} F^{μν} - A_μ J^μ

In this implementation we set μ₀ = 1. It is a TODO to introduce this constant.

ii. Key results

    freeCurrentPotential : The potential energy from the interaction of the electromagnetic potential with a free Lorentz current density.

    gradFreeCurrentPotential : The variational gradient of the free current potential.

    lagrangian : The lagrangian density for the electromagnetic field in presence of a Lorentz current density.

    gradLagrangian : The variational gradient of the lagrangian density.

    gradLagrangian_eq_electricField_magneticField : The variational gradient of the lagrangian density expressed in Gauss's and Ampère laws.

iii. Table of contents

    A. Free current potential

      A.1. Shifts in the free current potential under shifts in the potential

      A.2. The free current potential has a variational gradient

      A.3. The free current potential in terms of the scalar and vector potentials

      A.4. The variational gradient of the free current potential

    B. The Lagrangian density

      B.1. Shifts in the lagrangian under shifts in the potential

      B.2. Lagrangian in terms of electric and magnetic fields

    C. The variational gradient of the lagrangian density

      C.1. The lagrangian density has a variational gradient

      C.2. The definition of, gradLagrangian, the variational gradient of the lagrangian density

      C.3. The variational gradient in terms of the gradient of the kinetic term

      C.4. The lagrangian density has the variational gradient equal to gradLagrangian

      C.5. The variational gradient in terms of the field strength tensor

      C.6. The lagrangian gradient recovering Gauss's and Ampère laws

      C.7. The lagrangian gradient in tensor notation

iv. References

    https://quantummechanics.ucsd.edu/ph130a/130_notes/node452.html

    https://ph.qmul.ac.uk/sites/default/files/EMT10new.pdf

@[expose] public sectionattribute [-simp] Fintype.sum_sum_typeattribute [-simp] Nat.succ_eq_add_one

A. Free current potential

A.1. Shifts in the free current potential under shifts in the potential

lemma freeCurrentPotential_add_const (A : ElectromagneticPotential d) (J : LorentzCurrentDensity d) (c : Lorentz.Vector d) (x : SpaceTime d) : freeCurrentPotential fun x => A x + c J x = freeCurrentPotential A J x + c, J x⟫ₘ := d:A:ElectromagneticPotential dJ:LorentzCurrentDensity dc:Lorentz.Vector dx:SpaceTime d{ val := fun x => A.val x + c }.freeCurrentPotential J x = A.freeCurrentPotential J x + (minkowskiProduct c) (J x) All goals completed! 🐙

A.2. The free current potential has a variational gradient

d:A:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jμ:Fin 1 Fin dh1:HasVarAdjDerivAt (fun A' x => A' x μ) (fun A' x => A' x Lorentz.Vector.basis μ) A.valh2':ContDiff fun x => η μ μ * J x μh2:HasVarAdjDerivAt (fun φ x => η μ μ * φ x μ * J x μ) (fun ψ x => (fun x' => η μ μ * J x' μ * ψ x') x Lorentz.Vector.basis μ) A.valh3':(fun φ x => η μ μ * J x μ * φ x μ) = fun φ x => η μ μ * φ x μ * J x μHasVarGradientAt (fun v x => η μ μ * { val := v }.val x μ * J x μ) (fun x => (η μ μ * J x μ) Lorentz.Vector.basis μ) A.val d:A:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jμ:Fin 1 Fin dh1:HasVarAdjDerivAt (fun A' x => A' x μ) (fun A' x => A' x Lorentz.Vector.basis μ) A.valh2':ContDiff fun x => η μ μ * J x μh2:HasVarAdjDerivAt (fun φ x => η μ μ * φ x μ * J x μ) (fun ψ x => (fun x' => η μ μ * J x' μ * ψ x') x Lorentz.Vector.basis μ) A.valh3':(fun φ x => η μ μ * J x μ * φ x μ) = fun φ x => η μ μ * φ x μ * J x μ(fun x => (η μ μ * J x μ) Lorentz.Vector.basis μ) = fun x => (fun x' => η μ μ * J x' μ * (fun x => 1) x') x Lorentz.Vector.basis μ All goals completed! 🐙

A.3. The free current potential in terms of the scalar and vector potentials

d:𝓕:FreeSpaceA:ElectromagneticPotential dJ:LorentzCurrentDensity dx:SpaceTime d μ, η μ μ * A.val x μ * J x μ = scalarPotential 𝓕.c A ((time 𝓕.c) x) (space x) * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x) - i, (vectorPotential 𝓕.c A ((time 𝓕.c) x) (space x)).ofLp i * (LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp i d:𝓕:FreeSpaceA:ElectromagneticPotential dJ:LorentzCurrentDensity dx:SpaceTime dA.val x (Sum.inl 0) * J x (Sum.inl 0) + - x_1, A.val x (Sum.inr x_1) * J x (Sum.inr x_1) = 𝓕.c.val * A.val x (Sum.inl 0) * (𝓕.c.val⁻¹ * J x (Sum.inl 0)) - x_1, A.val x (Sum.inr x_1) * J x (Sum.inr x_1) d:𝓕:FreeSpaceA:ElectromagneticPotential dJ:LorentzCurrentDensity dx:SpaceTime dA.val x (Sum.inl 0) * J x (Sum.inl 0) + - x_1, A.val x (Sum.inr x_1) * J x (Sum.inr x_1) = A.val x (Sum.inl 0) * J x (Sum.inl 0) - x_1, A.val x (Sum.inr x_1) * J x (Sum.inr x_1) All goals completed! 🐙

A.4. The variational gradient of the free current potential

lemma gradFreeCurrentPotential_eq_sum_basis {d} (A : ElectromagneticPotential d) (hA : ContDiff A) (J : LorentzCurrentDensity d) (hJ : ContDiff J) : A.gradFreeCurrentPotential J = ( μ, fun x => (η μ μ * J x μ) Lorentz.Vector.basis μ) := d:A:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff JA.gradFreeCurrentPotential J = μ, fun x => (η μ μ * J x μ) Lorentz.Vector.basis μ All goals completed! 🐙d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime d((∑ a₁, fun x => (η (Sum.inl a₁) (Sum.inl a₁) * J x (Sum.inl a₁)) Lorentz.Vector.basis (Sum.inl a₁)) + a₂, fun x => (η (Sum.inr a₂) (Sum.inr a₂) * J x (Sum.inr a₂)) Lorentz.Vector.basis (Sum.inr a₂)) x = (𝓕.c.val * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x)) Lorentz.Vector.basis (Sum.inl 0) + i, -(LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp i Lorentz.Vector.basis (Sum.inr i) d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dJ x (Sum.inl 0) Lorentz.Vector.basis (Sum.inl 0) + c, -(J x (Sum.inr c) Lorentz.Vector.basis (Sum.inr c)) = (𝓕.c.val * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x)) Lorentz.Vector.basis (Sum.inl 0) + x_1, -((LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp x_1 Lorentz.Vector.basis (Sum.inr x_1)) d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dJ x (Sum.inl 0) = 𝓕.c.val * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x)d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime d(fun c => -(J x (Sum.inr c) Lorentz.Vector.basis (Sum.inr c))) = fun x_1 => -((LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp x_1 Lorentz.Vector.basis (Sum.inr x_1)) d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dJ x (Sum.inl 0) = 𝓕.c.val * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x)d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime d(fun c => -(J x (Sum.inr c) Lorentz.Vector.basis (Sum.inr c))) = fun x_1 => -((LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp x_1 Lorentz.Vector.basis (Sum.inr x_1)) All goals completed! 🐙d:A:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin d(∑ μ, fun x => (η μ μ * J x μ) Lorentz.Vector.basis μ) x ν = η ν ν * J x ν All goals completed! 🐙

B. The Lagrangian density

The lagrangian density for the electromagnetic field in presence of a current density J is L = -1/(4 μ₀) F_{μν} F^{μν} - A_μ J^μ

B.1. Shifts in the lagrangian under shifts in the potential

d:𝓕:FreeSpaceA:ElectromagneticPotential dJ:LorentzCurrentDensity dc:Lorentz.Vector dx:SpaceTime dkineticTerm 𝓕 A x - (A.freeCurrentPotential J x + (minkowskiProduct c) (J x)) = kineticTerm 𝓕 A x - A.freeCurrentPotential J x - (minkowskiProduct c) (J x) All goals completed! 🐙

B.2. Lagrangian in terms of electric and magnetic fields

The Lagrangian is equal to 1/2 * (ε₀ E^2 - 1/μ₀ B^2) - φρ + A · j

d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff 2 A.valJ:LorentzCurrentDensity dx:SpaceTime d1 / 2 * (𝓕.ε₀ * electricField 𝓕.c A ((time 𝓕.c) x) (space x) ^ 2 - 1 / (2 * 𝓕.μ₀) * i, j, magneticFieldMatrix 𝓕.c A ((time 𝓕.c) x) (space x) (i, j) ^ 2) - (scalarPotential 𝓕.c A ((time 𝓕.c) x) (space x) * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x) - i, (vectorPotential 𝓕.c A ((time 𝓕.c) x) (space x)).ofLp i * (LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp i) = 1 / 2 * (𝓕.ε₀ * electricField 𝓕.c A ((time 𝓕.c) x) (space x) ^ 2 - 1 / (2 * 𝓕.μ₀) * i, j, magneticFieldMatrix 𝓕.c A ((time 𝓕.c) x) (space x) (i, j) ^ 2) - scalarPotential 𝓕.c A ((time 𝓕.c) x) (space x) * LorentzCurrentDensity.chargeDensity 𝓕.c J ((time 𝓕.c) x) (space x) + i, (vectorPotential 𝓕.c A ((time 𝓕.c) x) (space x)).ofLp i * (LorentzCurrentDensity.currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp i All goals completed! 🐙

C. The variational gradient of the lagrangian density

C.1. The lagrangian density has a variational gradient

All goals completed! 🐙

C.2. The definition of, gradLagrangian, the variational gradient of the lagrangian density

C.3. The variational gradient in terms of the gradient of the kinetic term

lemma gradLagrangian_eq_kineticTerm_sub {𝓕 : FreeSpace} (A : ElectromagneticPotential d) (hA : ContDiff A) (J : LorentzCurrentDensity d) (hJ : ContDiff J) : A.gradLagrangian 𝓕 J = A.gradKineticTerm 𝓕 - A.gradFreeCurrentPotential J := d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff JgradLagrangian 𝓕 A J = gradKineticTerm 𝓕 A - A.gradFreeCurrentPotential J All goals completed! 🐙

C.4. The lagrangian density has the variational gradient equal to gradLagrangian

d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff JHasVarGradientAt (fun A => lagrangian 𝓕 { val := A } J) (gradKineticTerm 𝓕 A - A.gradFreeCurrentPotential J) A.val All goals completed! 🐙

C.5. The variational gradient in terms of the field strength tensor

d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime d x_1, ((𝓕.μ₀⁻¹ * η x_1 x_1) (∑ μ, ∂_ μ (fun x => (A.fieldStrengthMatrix x) (μ, x_1)) x) Lorentz.Vector.basis x_1 - (η x_1 x_1 * J x x_1) Lorentz.Vector.basis x_1) = x_1, η x_1 x_1 (𝓕.μ₀⁻¹ * μ, ∂_ μ (fun x => (A.fieldStrengthMatrix x) (μ, x_1)) x - J x x_1) Lorentz.Vector.basis x_1d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dContDiff A.val d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin dx✝:ν Finset.univ(𝓕.μ₀⁻¹ * η ν ν) (∑ μ, ∂_ μ (fun x => (A.fieldStrengthMatrix x) (μ, ν)) x) Lorentz.Vector.basis ν - (η ν ν * J x ν) Lorentz.Vector.basis ν = η ν ν (𝓕.μ₀⁻¹ * μ, ∂_ μ (fun x => (A.fieldStrengthMatrix x) (μ, ν)) x - J x ν) Lorentz.Vector.basis νd:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dContDiff A.val d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dContDiff A.val All goals completed! 🐙

C.6. The lagrangian gradient recovering Gauss's and Ampère laws

d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime di:Fin dx✝:i Finset.univ(𝓕.μ₀⁻¹ * (𝓕.ε₀ * 𝓕.μ₀ * (∂ₜ (fun t => electricField 𝓕.c A t (space x)) ((time 𝓕.c) x)).ofLp i - j, Space.deriv j (fun x_1 => magneticFieldMatrix 𝓕.c A ((time 𝓕.c) x) x_1 (j, i)) (space x))) Lorentz.Vector.basis (Sum.inr i) - -(currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp i Lorentz.Vector.basis (Sum.inr i) = (𝓕.μ₀⁻¹ * (𝓕.ε₀ * 𝓕.μ₀ * (∂ₜ (fun x_1 => electricField 𝓕.c A x_1 (space x)) ((time 𝓕.c) x)).ofLp i - j, Space.deriv j (fun x_1 => magneticFieldMatrix 𝓕.c A ((time 𝓕.c) x) x_1 (j, i)) (space x)) + (currentDensity 𝓕.c J ((time 𝓕.c) x) (space x)).ofLp i) Lorentz.Vector.basis (Sum.inr i) All goals completed! 🐙

C.7. The lagrangian gradient in tensor notation

d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin dJ x ν = Tensorial.toTensor.symm (Tensorial.toTensor (J x)) νd:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin d![0] = id d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin d![0] = id d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin di:Fin (Nat.succ 0)![0] i = id i d:𝓕:FreeSpaceA:ElectromagneticPotential dhA:ContDiff A.valJ:LorentzCurrentDensity dhJ:ContDiff Jx:SpaceTime dν:Fin 1 Fin d![0] ((fun i => i) 0, ) = id ((fun i => i) 0, ) All goals completed! 🐙