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, Lode Vermeulen
-/
module
public import Physlib.ClassicalMechanics.EulerLagrange
public import Physlib.ClassicalMechanics.HamiltonsEquations
public import Mathlib.Algebra.Order.Archimedean.Real.HomThe Classical Harmonic Oscillator
i. Overview
The classical harmonic oscillator is a classical mechanical system corresponding to a
mass m under a force - k x where k is the spring constant and x is the position.
In this file, a coordinate system is assumed where position and velocity both have type
EuclideanSpace ℝ (Fin 1). This is a simpler model often used for pedagogical purpose,
but only works because both the configuration space (position) and its tangent space (velocity)
are isomorphic to Euclidean Space. A proper formalisation should include the geometric properties
of the state space via manifolds and tangent bundles.
ii. Key results
The key results in the study of the classical harmonic oscillator are the follows:
In the Basic module:
HarmonicOscillator contains the input data to the problem.
EquationOfMotion defines the equation of motion for the harmonic oscillator.
energy_conservation_of_equationOfMotion proves that a trajectory satisfying the
equation of motion conserves energy.
equationOfMotion_tfae proves that the equation of motion of motion is equivalent to
Newton's second law,
Hamilton's equations,
the variational principal for the action,
the Hamilton variation principal.
In the Solution module:
InitialConditions is a structure for the initial conditions for the harmonic oscillator.
trajectories is the trajectories to the harmonic oscillator for given initial conditions.
trajectories_equationOfMotion proves that the solution satisfies the equation of motion.
iii. Table of contents
A. The input data
B. The angular frequency
C. The energies
C.1. The definitions of the energies
C.2. Simple equalities for the energies
C.3. Differentiability of the energies
C.4. Time derivatives of the energies
D. Lagrangian and the equation of motion
D.1. The Lagrangian
D.1.1. Equalities for the lagrangian
D.1.2. Smoothness of the lagrangian
D.1.3. Gradients of the lagrangian
D.2. The variational derivative of the action
D.2.1. Equality for the variational derivative
D.3. The equation of motion
D.3.1. Equation of motion if and only if variational-gradient of Lagrangian is zero
E. Newton's second law
E.1. The force
E.1.1. The force is equal to - k x
E.2. Variational derivative of lagrangian and force
E.3. Equation of motion if and only if Newton's second law
F. Energy conservation
F.1. Energy conservation in terms of time derivatives
F.2. Energy conservation in terms of constant energy
G. Hamiltonian formulation
G.1. The canonical momentum
G.1.1. Equality for the canonical momentum
G.2. The Hamiltonian
G.2.1. Equality for the Hamiltonian
G.2.2. Smoothness of the Hamiltonian
G.2.3. Gradients of the Hamiltonian
G.3. Relation between Hamiltonian and energy
G.4. Hamilton equation operator
G.5. Equation of motion if and only if Hamilton's equations
H. Equivalences between the different formulations of the equations of motion
iv. References
References for the classical harmonic oscillator include:
Landau & Lifshitz, Mechanics, page 58, section 21.
@[expose] public sectionTODO "Create a new file for the geometric model which properly models the position as a
configuration space and velocity as its tangent space, then show explicitly how this
coordinate model is a simplification of the geometric model.
A nice reference for such an analysis is:
https://web.williams.edu/Mathematics/it3/texts/var_noether.pdf"A. The input data
We start by defining a structure containing the input data of the harmonic oscillator, and
proving basic properties thereof. The input data consists of the mass m
of the particle and the spring constant k.
The classical harmonic oscillator is specified by a mass m, and a spring constant k.
Both the mass and the string constant are assumed to be positive.
The mass of the harmonic Oscillator.
The spring constant of the harmonic oscillator.
structure HarmonicOscillator where m : ℝ k : ℝ
m_pos : 0 < m
k_pos : 0 < kB. The angular frequency
From the input data, it is possible to define the angular frequency ω of the harmonic oscillator,
as √(k/m).
The angular frequency appears in the solutions to the equations of motion of the harmonic oscillator.
Here we both define and prove properties related to the angular frequency.
The angular frequency of the classical harmonic oscillator is positive.
The square of the angular frequency of the classical harmonic oscillator is equal to k/m.
The angular frequency of the classical harmonic oscillator is not equal to zero.
The inverse of the square of the angular frequency of the classical harmonic oscillator
is m/k.
All goals completed! 🐙C. The energies
The harmonic oscillator has a kinetic energy determined by it's velocity and a potential energy determined by it's position. These combine to give the total energy of the harmonic oscillator.
Here we state and prove a number of properties of these energies.
C.1. The definitions of the energies
We define the three energies, it is these energies which will control the dynamics of the harmonic oscillator, through the lagrangian.
C.2. Simple equalities for the energies
lemma kineticEnergy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) :
kineticEnergy S xₜ = fun t => (1 / (2 : ℝ)) * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ:= by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)⊢ S.kineticEnergy xₜ = fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ rfl All goals completed! 🐙lemma potentialEnergy_eq (x : EuclideanSpace ℝ (Fin 1)) :
potentialEnergy S x = (1 / (2 : ℝ)) • S.k • ⟪x, x⟫_ℝ:= by S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)⊢ S.potentialEnergy x = (1 / 2) • S.k • ⟪x, x⟫_ℝ rfl All goals completed! 🐙lemma energy_eq (xₜ : Time → EuclideanSpace ℝ (Fin 1)) :
energy S xₜ = fun t => kineticEnergy S xₜ t + potentialEnergy S (xₜ t) := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)⊢ S.energy xₜ = fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t) rfl All goals completed! 🐙C.3. Differentiability of the energies
On smooth trajectories the energies are differentiable.
@[fun_prop]
lemma kineticEnergy_differentiable (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
Differentiable ℝ (kineticEnergy S xₜ) := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ (S.kineticEnergy xₜ)
rw [kineticEnergy_eq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ
fun_prop All goals completed! 🐙
@[fun_prop]
lemma potentialEnergy_differentiable (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
Differentiable ℝ (fun t => potentialEnergy S (xₜ t)) := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => S.potentialEnergy (xₜ t)
have hd : Differentiable ℝ xₜ := hx.differentiable (by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ∞ ≠ 0 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜhd:Differentiable ℝ xₜ⊢ Differentiable ℝ fun t => S.potentialEnergy (xₜ t) simp All goals completed! 🐙 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜhd:Differentiable ℝ xₜ⊢ Differentiable ℝ fun t => S.potentialEnergy (xₜ t)) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜhd:Differentiable ℝ xₜ⊢ Differentiable ℝ fun t => S.potentialEnergy (xₜ t)
simp only [potentialEnergy_eq] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜhd:Differentiable ℝ xₜ⊢ Differentiable ℝ fun t => (1 / 2) • S.k • ⟪xₜ t, xₜ t⟫_ℝ
fun_prop All goals completed! 🐙
@[fun_prop]
lemma energy_differentiable (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
Differentiable ℝ (energy S xₜ) := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ (S.energy xₜ)
rw [energy_eq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t)] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ Differentiable ℝ fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t)
fun_prop All goals completed! 🐙C.4. Time derivatives of the energies
For a general smooth trajectory (which may not satisfy the equations of motion) we can compute the time derivatives of the energies.
lemma kineticEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
∂ₜ (kineticEnergy S xₜ) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ∂ₜ (S.kineticEnergy xₜ) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ
funext t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ ∂ₜ (S.kineticEnergy xₜ) t = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ
unfold kineticEnergy S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ ∂ₜ (fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ) t = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ
have hd : DifferentiableAt ℝ (∂ₜ xₜ) t :=
(deriv_differentiable_of_contDiff xₜ hx).differentiableAt S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ ∂ₜ (fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ) t = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ
rw [Time.deriv_eq, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (fderiv ℝ (fun t => 1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ) t) 1 = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ fderiv_const_mul (by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ DifferentiableAt ℝ (fun t => ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ) t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ fun_prop All goals completed! 🐙 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ), _root_.smul_apply, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (fderiv ℝ (fun t => ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ) t) 1 = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ
fderiv_inner_apply (𝕜 := ℝ) hd hd, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, (fderiv ℝ (∂ₜ xₜ) t) 1⟫_ℝ + ⟪(fderiv ℝ (∂ₜ xₜ) t) 1, ∂ₜ xₜ t⟫_ℝ) =
⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ ← Time.deriv_eq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ (1 / 2 * S.m) • (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ (∂ₜ xₜ) t, ∂ₜ xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t⟫_ℝ
simp [inner_smul_right, real_inner_comm] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ (∂ₜ xₜ) t⊢ 2⁻¹ * S.m * (⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ + ⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ) = S.m * ⟪∂ₜ xₜ t, ∂ₜ (∂ₜ xₜ) t⟫_ℝ
ring All goals completed! 🐙
lemma potentialEnergy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
∂ₜ (fun t => potentialEnergy S (xₜ t)) = fun t => ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∂ₜ fun t => S.potentialEnergy (xₜ t)) = fun t => ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ
funext t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ ∂ₜ (fun t => S.potentialEnergy (xₜ t)) t = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ
have hd : DifferentiableAt ℝ xₜ t := (hx.differentiable (by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ ∞ ≠ 0 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ ∂ₜ (fun t => S.potentialEnergy (xₜ t)) t = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ simp All goals completed! 🐙 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ ∂ₜ (fun t => S.potentialEnergy (xₜ t)) t = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ)).differentiableAt S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ ∂ₜ (fun t => S.potentialEnergy (xₜ t)) t = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ
simp only [potentialEnergy_eq, smul_eq_mul, ← mul_assoc] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ ∂ₜ (fun t => 1 / 2 * S.k * ⟪xₜ t, xₜ t⟫_ℝ) t = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ
rw [Time.deriv_eq, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (fderiv ℝ (fun t => 1 / 2 * S.k * ⟪xₜ t, xₜ t⟫_ℝ) t) 1 = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ fderiv_const_mul (by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ DifferentiableAt ℝ (fun t => ⟪xₜ t, xₜ t⟫_ℝ) t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ fun_prop All goals completed! 🐙 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ), _root_.smul_apply, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (fderiv ℝ (fun t => ⟪xₜ t, xₜ t⟫_ℝ) t) 1 = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ
fderiv_inner_apply (𝕜 := ℝ) hd hd, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, (fderiv ℝ xₜ t) 1⟫_ℝ + ⟪(fderiv ℝ xₜ t) 1, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ ← Time.deriv_eq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ (1 / 2 * S.k) • (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪∂ₜ xₜ t, xₜ t⟫_ℝ) = ⟪∂ₜ xₜ t, S.k • xₜ t⟫_ℝ
simp [inner_smul_right, real_inner_comm] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Timehd:DifferentiableAt ℝ xₜ t⊢ 2⁻¹ * S.k * (⟪xₜ t, ∂ₜ xₜ t⟫_ℝ + ⟪xₜ t, ∂ₜ xₜ t⟫_ℝ) = S.k * ⟪xₜ t, ∂ₜ xₜ t⟫_ℝ
ring All goals completed! 🐙
lemma energy_deriv (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
∂ₜ (energy S xₜ) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ∂ₜ (S.energy xₜ) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ
unfold energy S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∂ₜ fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t)) = fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ
funext t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ ∂ₜ (fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t)) t = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ
rw [Time.deriv_eq, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ (fderiv ℝ (fun t => S.kineticEnergy xₜ t + S.potentialEnergy (xₜ t)) t) 1 = ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ (fderiv ℝ (S.kineticEnergy xₜ) t + fderiv ℝ (fun t => S.potentialEnergy (xₜ t)) t) 1 =
⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ fderiv_fun_add (by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ DifferentiableAt ℝ (S.kineticEnergy xₜ) t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ (fderiv ℝ (S.kineticEnergy xₜ) t + fderiv ℝ (fun t => S.potentialEnergy (xₜ t)) t) 1 =
⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ fun_prop All goals completed! 🐙 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ (fderiv ℝ (S.kineticEnergy xₜ) t + fderiv ℝ (fun t => S.potentialEnergy (xₜ t)) t) 1 =
⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ) (S.potentialEnergy_differentiable xₜ hx t)] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ (fderiv ℝ (S.kineticEnergy xₜ) t + fderiv ℝ (fun t => S.potentialEnergy (xₜ t)) t) 1 =
⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ
simp only [_root_.add_apply, ← Time.deriv_eq, kineticEnergy_deriv _ _ hx,
potentialEnergy_deriv _ _ hx, ← inner_add_right] All goals completed! 🐙D. Lagrangian and the equation of motion
We state the lagrangian, and derive from that the equation of motion for the harmonic oscillator.
D.1. The Lagrangian
We define the lagrangian of the harmonic oscillator, as a function of phase-space. It is given by
$$L(t, x, v) := \frac{1}{2} m ‖v‖^2 - \frac{1}{2} k ‖x‖^2$$
In theory this definition is the kinetic energy minus the potential energy, however to make the lagrangian a function on phase-space we reserve this result for a lemma.
The lagrangian of the harmonic oscillator is the kinetic energy minus the potential energy.
set_option linter.unusedVariables false in@[nolint unusedArguments]
noncomputable def lagrangian (t : Time) (x : EuclideanSpace ℝ (Fin 1))
(v : EuclideanSpace ℝ (Fin 1)) : ℝ :=
1 / (2 : ℝ) * S.m * ⟪v, v⟫_ℝ - S.potentialEnergy xD.1.1. Equalities for the lagrangian
Equalities for the lagrangian. We prove some simple equalities for the lagrangian, in particular that when applied to a trajectory it is the kinetic energy minus the potential energy.
set_option linter.unusedVariables false in
@[nolint unusedArguments]
lemma lagrangian_eq : lagrangian S = fun t x v =>
1 / (2 : ℝ) * S.m * ⟪v, v⟫_ℝ - 1 / (2 : ℝ) * S.k * ⟪x, x⟫_ℝ := by S:HarmonicOscillator⊢ S.lagrangian = fun t x v => 1 / 2 * S.m * ⟪v, v⟫_ℝ - 1 / 2 * S.k * ⟪x, x⟫_ℝ
ext t x v S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)⊢ S.lagrangian t x v = 1 / 2 * S.m * ⟪v, v⟫_ℝ - 1 / 2 * S.k * ⟪x, x⟫_ℝ
simp [lagrangian, potentialEnergy, mul_assoc] All goals completed! 🐙lemma lagrangian_eq_kineticEnergy_sub_potentialEnergy (t : Time)
(xₜ : Time → EuclideanSpace ℝ (Fin 1)) :
lagrangian S t (xₜ t) (∂ₜ xₜ t) = kineticEnergy S xₜ t - potentialEnergy S (xₜ t) := by S:HarmonicOscillatort:Timexₜ:Time → EuclideanSpace ℝ (Fin 1)⊢ S.lagrangian t (xₜ t) (∂ₜ xₜ t) = S.kineticEnergy xₜ t - S.potentialEnergy (xₜ t)
rfl All goals completed! 🐙D.1.2. Smoothness of the lagrangian
The lagrangian is smooth in all its arguments.
@[fun_prop]
lemma contDiff_lagrangian (n : WithTop ℕ∞) : ContDiff ℝ n ↿S.lagrangian := by S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿S.lagrangian
rw [lagrangian_eq S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿fun t x v => 1 / 2 * S.m * ⟪v, v⟫_ℝ - 1 / 2 * S.k * ⟪x, x⟫_ℝ S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿fun t x v => 1 / 2 * S.m * ⟪v, v⟫_ℝ - 1 / 2 * S.k * ⟪x, x⟫_ℝ] S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿fun t x v => 1 / 2 * S.m * ⟪v, v⟫_ℝ - 1 / 2 * S.k * ⟪x, x⟫_ℝ
fun_prop All goals completed! 🐙lemma toDual_symm_innerSL (x : EuclideanSpace ℝ (Fin 1)) :
(InnerProductSpace.toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (innerSL ℝ x) = x :=
(InnerProductSpace.toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm_apply_apply x
lemma gradient_inner_self (x : EuclideanSpace ℝ (Fin 1)) :
gradient (fun y : EuclideanSpace ℝ (Fin 1) => ⟪y, y⟫_ℝ) x = (2 : ℝ) • x := by x:EuclideanSpace ℝ (Fin 1)⊢ gradient (fun y => ⟪y, y⟫_ℝ) x = 2 • x
refine ext_inner_right (𝕜 := ℝ) fun y => ?_ x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ ⟪gradient (fun y => ⟪y, y⟫_ℝ) x, y⟫_ℝ = ⟪2 • x, y⟫_ℝ
unfold gradient x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ ⟪(toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x), y⟫_ℝ = ⟪2 • x, y⟫_ℝ
rw [InnerProductSpace.toDual_symm_apply, x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x) y = ⟪2 • x, y⟫_ℝ x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ ⟪x, (fderiv ℝ (fun x => x) x) y⟫_ℝ + ⟪(fderiv ℝ (fun x => x) x) y, x⟫_ℝ = ⟪2 • x, y⟫_ℝ
fderiv_inner_apply (𝕜 := ℝ) differentiableAt_fun_id differentiableAt_fun_id x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ ⟪x, (fderiv ℝ (fun x => x) x) y⟫_ℝ + ⟪(fderiv ℝ (fun x => x) x) y, x⟫_ℝ = ⟪2 • x, y⟫_ℝ x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ ⟪x, (fderiv ℝ (fun x => x) x) y⟫_ℝ + ⟪(fderiv ℝ (fun x => x) x) y, x⟫_ℝ = ⟪2 • x, y⟫_ℝ] x:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ ⟪x, (fderiv ℝ (fun x => x) x) y⟫_ℝ + ⟪(fderiv ℝ (fun x => x) x) y, x⟫_ℝ = ⟪2 • x, y⟫_ℝ
simp [real_inner_comm, inner_smul_right, two_mul] All goals completed! 🐙
lemma gradient_const_mul_inner_self (c : ℝ) (x : EuclideanSpace ℝ (Fin 1)) :
gradient (fun y : EuclideanSpace ℝ (Fin 1) => c * ⟪y, y⟫_ℝ) x = (2 * c) • x := by c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ gradient (fun y => c * ⟪y, y⟫_ℝ) x = (2 * c) • x
unfold gradient c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ (toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => c * ⟪y, y⟫_ℝ) x) = (2 * c) • x
rw [fderiv_const_mul (by c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ DifferentiableAt ℝ (fun y => ⟪y, y⟫_ℝ) x c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • (toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x) = (2 * c) • x fun_prop All goals completed! 🐙 c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • (toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x) = (2 * c) • x) c, map_smul c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • (toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x) = (2 * c) • x c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • (toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x) = (2 * c) • x] c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • (toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv ℝ (fun y => ⟪y, y⟫_ℝ) x) = (2 * c) • x
show c • gradient (fun y : EuclideanSpace ℝ (Fin 1) => ⟪y, y⟫_ℝ) x = (2 * c) • x c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • gradient (fun y => ⟪y, y⟫_ℝ) x = (2 * c) • x
rw [gradient_inner_self, c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ c • 2 • x = (2 * c) • x All goals completed! 🐙 smul_smul, c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ (c * 2) • x = (2 * c) • x All goals completed! 🐙 mul_comm c:ℝx:EuclideanSpace ℝ (Fin 1)⊢ (2 * c) • x = (2 * c) • x All goals completed! 🐙] All goals completed! 🐙D.1.3. Gradients of the lagrangian
We now show results related to the gradients of the lagrangian with respect to the position and velocity.
private lemma gradient_add_const' {f : EuclideanSpace ℝ (Fin 1) → ℝ} {c : ℝ}
(x : EuclideanSpace ℝ (Fin 1)) :
gradient (fun y => f y + c) x = gradient f x :=
congrArg (InnerProductSpace.toDual ℝ (EuclideanSpace ℝ (Fin 1))).symm (fderiv_add_const c)
lemma gradient_lagrangian_position_eq (t : Time) (x : EuclideanSpace ℝ (Fin 1))
(v : EuclideanSpace ℝ (Fin 1)) :
gradient (fun x => lagrangian S t x v) x = - S.k • x := by S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)⊢ gradient (fun x => S.lagrangian t x v) x = -S.k • x
have h_eq : (fun y : EuclideanSpace ℝ (Fin 1) => lagrangian S t y v) =
fun y => (-(1 / (2 : ℝ)) * S.k) * ⟪y, y⟫_ℝ + (1 / (2 : ℝ) * S.m * ⟪v, v⟫_ℝ) := by
funext y S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ S.lagrangian t y v = -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ gradient (fun x => S.lagrangian t x v) x = -S.k • x; simp only [lagrangian_eq] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ 1 / 2 * S.m * ⟪v, v⟫_ℝ - 1 / 2 * S.k * ⟪y, y⟫_ℝ = -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ gradient (fun x => S.lagrangian t x v) x = -S.k • x; ring S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ gradient (fun x => S.lagrangian t x v) x = -S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ gradient (fun x => S.lagrangian t x v) x = -S.k • x
rw [h_eq, S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ gradient (fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ) x = -S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ (2 * (-(1 / 2) * S.k)) • x = -S.k • x gradient_add_const', S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ gradient (fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ) x = -S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ (2 * (-(1 / 2) * S.k)) • x = -S.k • x gradient_const_mul_inner_self S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ (2 * (-(1 / 2) * S.k)) • x = -S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ (2 * (-(1 / 2) * S.k)) • x = -S.k • x] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t y v) = fun y => -(1 / 2) * S.k * ⟪y, y⟫_ℝ + 1 / 2 * S.m * ⟪v, v⟫_ℝ⊢ (2 * (-(1 / 2) * S.k)) • x = -S.k • x
module All goals completed! 🐙
lemma gradient_lagrangian_velocity_eq (t : Time) (x : EuclideanSpace ℝ (Fin 1))
(v : EuclideanSpace ℝ (Fin 1)) :
gradient (lagrangian S t x) v = S.m • v := by S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)⊢ gradient (S.lagrangian t x) v = S.m • v
have h_eq : (fun y : EuclideanSpace ℝ (Fin 1) => lagrangian S t x y) =
fun y => ((1 / (2 : ℝ)) * S.m) * ⟪y, y⟫_ℝ + (-(1 / (2 : ℝ)) * S.k * ⟪x, x⟫_ℝ) := by
funext y S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ S.lagrangian t x y = 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (S.lagrangian t x) v = S.m • v; simp only [lagrangian_eq] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ 1 / 2 * S.m * ⟪y, y⟫_ℝ - 1 / 2 * S.k * ⟪x, x⟫_ℝ = 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (S.lagrangian t x) v = S.m • v; ring S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (S.lagrangian t x) v = S.m • v S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (S.lagrangian t x) v = S.m • v
change gradient (fun y : EuclideanSpace ℝ (Fin 1) => lagrangian S t x y) v = S.m • v S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun y => S.lagrangian t x y) v = S.m • v
rw [h_eq, S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ) v = S.m • v S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * S.m)) • v = S.m • v gradient_add_const', S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ) v = S.m • v S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * S.m)) • v = S.m • v gradient_const_mul_inner_self S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * S.m)) • v = S.m • v S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * S.m)) • v = S.m • v] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)v:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.lagrangian t x y) = fun y => 1 / 2 * S.m * ⟪y, y⟫_ℝ + -(1 / 2) * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * S.m)) • v = S.m • v
module All goals completed! 🐙D.2. The variational derivative of the action
We now write down the variational derivative for the harmonic oscillator, for a trajectory $x(t)$ this is equal to
$$t\mapsto \left.\frac{\partial L(t, \dot x (t), q)}{\partial q}\right|{q = x(t)} - \frac{d}{dt} \left.\frac{\partial L(t, v, x(t))}{\partial v}\right|{v = \dot x (t)}$$
Setting this equal to zero corresponds to the Euler-Lagrange equations, and thereby the equation of motion.
D.2.1. Equality for the variational derivative
Basic equalities for the variational derivative of the action.
lemma gradLagrangian_eq_eulerLagrangeOp (xₜ : Time → EuclideanSpace ℝ (Fin 1))
(hq : ContDiff ℝ ∞ xₜ) :
gradLagrangian S xₜ = eulerLagrangeOp S.lagrangian xₜ := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hq:ContDiff ℝ ∞ xₜ⊢ S.gradLagrangian xₜ = eulerLagrangeOp S.lagrangian xₜ
rw [gradLagrangian, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hq:ContDiff ℝ ∞ xₜ⊢ varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = eulerLagrangeOp S.lagrangian xₜ All goals completed! 🐙 euler_lagrange_varGradient _ _ hq (S.contDiff_lagrangian _) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hq:ContDiff ℝ ∞ xₜ⊢ eulerLagrangeOp S.lagrangian xₜ = eulerLagrangeOp S.lagrangian xₜ All goals completed! 🐙] All goals completed! 🐙D.3. The equation of motion
The equation of motion for the harmonic oscillator is given by setting the variational derivative of the action equal to zero.
The equation of motion for the Harmonic oscillator.
def EquationOfMotion (xₜ : Time → EuclideanSpace ℝ (Fin 1)) : Prop :=
S.gradLagrangian xₜ = 0D.3.1. Equation of motion if and only if variational-gradient of Lagrangian is zero
We write a simple iff statement for the definition of the equation of motions.
lemma equationOfMotion_iff_gradLagrangian_zero (xₜ : Time → EuclideanSpace ℝ (Fin 1)) :
S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)⊢ S.EquationOfMotion xₜ ↔ S.gradLagrangian xₜ = 0 rfl All goals completed! 🐙E. Newton's second law
We define the force of the harmonic oscillator, and show that the equation of motion is equivalent to Newton's second law.
E.1. The force
We define the force of the harmonic oscillator as the negative gradient of the potential energy,
and show that this is equal to - k x.
E.1.1. The force is equal to - k x
We now show that the force is equal to - k x.
The force on the classical harmonic oscillator is - k x.
lemma force_eq_linear (x : EuclideanSpace ℝ (Fin 1)) : force S x = - S.k • x := by S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)⊢ S.force x = -S.k • x
have hpot : potentialEnergy S = fun y : EuclideanSpace ℝ (Fin 1) =>
((1 / (2 : ℝ)) * S.k) * ⟪y, y⟫_ℝ := by
funext y S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ S.potentialEnergy y = 1 / 2 * S.k * ⟪y, y⟫_ℝ S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ S.force x = -S.k • x
simp [potentialEnergy, mul_assoc] S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ S.force x = -S.k • x S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ S.force x = -S.k • x
unfold force S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ -gradient S.potentialEnergy x = -S.k • x
rw [hpot, S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ -gradient (fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ) x = -S.k • x S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ -((2 * (1 / 2 * S.k)) • x) = -S.k • x gradient_const_mul_inner_self S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ -((2 * (1 / 2 * S.k)) • x) = -S.k • x S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ -((2 * (1 / 2 * S.k)) • x) = -S.k • x] S:HarmonicOscillatorx:EuclideanSpace ℝ (Fin 1)hpot:S.potentialEnergy = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ⊢ -((2 * (1 / 2 * S.k)) • x) = -S.k • x
module All goals completed! 🐙E.2. Variational derivative of lagrangian and force
We relate the variational derivative of lagrangian to the force, and show the relation to Newton's second law.
The Euler lagrange operator corresponds to Newton's second law.
lemma gradLagrangian_eq_force (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
S.gradLagrangian xₜ = fun t => force S (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.gradLagrangian xₜ = fun t => S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t
funext t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ S.gradLagrangian xₜ t = S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t
rw [gradLagrangian_eq_eulerLagrangeOp S xₜ hx, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ eulerLagrangeOp S.lagrangian xₜ t = S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ gradient (fun x => S.lagrangian t x (∂ₜ xₜ t)) (xₜ t) -
∂ₜ (fun t' => gradient (fun x => S.lagrangian t' (xₜ t') x) (∂ₜ xₜ t')) t =
S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t eulerLagrangeOp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ gradient (fun x => S.lagrangian t x (∂ₜ xₜ t)) (xₜ t) -
∂ₜ (fun t' => gradient (fun x => S.lagrangian t' (xₜ t') x) (∂ₜ xₜ t')) t =
S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ gradient (fun x => S.lagrangian t x (∂ₜ xₜ t)) (xₜ t) -
∂ₜ (fun t' => gradient (fun x => S.lagrangian t' (xₜ t') x) (∂ₜ xₜ t')) t =
S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜt:Time⊢ gradient (fun x => S.lagrangian t x (∂ₜ xₜ t)) (xₜ t) -
∂ₜ (fun t' => gradient (fun x => S.lagrangian t' (xₜ t') x) (∂ₜ xₜ t')) t =
S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t
simp [gradient_lagrangian_position_eq, gradient_lagrangian_velocity_eq, force_eq_linear,
Time.deriv_smul _ S.m (deriv_differentiable_of_contDiff xₜ hx)] All goals completed! 🐙E.3. Equation of motion if and only if Newton's second law
We show that the equation of motion is equivalent to Newton's second law.
lemma equationOfMotion_iff_newtons_2nd_law (xₜ : Time → EuclideanSpace ℝ (Fin 1))
(hx : ContDiff ℝ ∞ xₜ) :
S.EquationOfMotion xₜ ↔
(∀ t, S.m • ∂ₜ (∂ₜ xₜ) t = force S (xₜ t)) := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)
rw [EquationOfMotion, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.gradLagrangian xₜ = 0 ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (x : Time), S.force (xₜ x) - S.m • ∂ₜ (∂ₜ xₜ) x = 0 x) ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t) gradLagrangian_eq_force S xₜ hx, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (fun t => S.force (xₜ t) - S.m • ∂ₜ (∂ₜ xₜ) t) = 0 ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (x : Time), S.force (xₜ x) - S.m • ∂ₜ (∂ₜ xₜ) x = 0 x) ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t) funext_iff S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (x : Time), S.force (xₜ x) - S.m • ∂ₜ (∂ₜ xₜ) x = 0 x) ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (x : Time), S.force (xₜ x) - S.m • ∂ₜ (∂ₜ xₜ) x = 0 x) ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (x : Time), S.force (xₜ x) - S.m • ∂ₜ (∂ₜ xₜ) x = 0 x) ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)
simp only [Pi.zero_apply, sub_eq_zero] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (x : Time), S.force (xₜ x) = S.m • ∂ₜ (∂ₜ xₜ) x) ↔ ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)
exact forall_congr' fun t => eq_comm All goals completed! 🐙F. Energy conservation
In this section we show that any trajectory satisfying the equation of motion conserves energy. This result simply follows from the definition of the energies, and their derivatives, as well as the statement that the equations of motion are equivalent to Newton's second law.
F.1. Energy conservation in terms of time derivatives
We prove that the time derivative of the energy is zero for any trajectory satisfying the equation of motion.
lemma energy_conservation_of_equationOfMotion (xₜ : Time → EuclideanSpace ℝ (Fin 1))
(hx : ContDiff ℝ ∞ xₜ)
(h : S.EquationOfMotion xₜ) : ∂ₜ (S.energy xₜ) = 0 := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜ⊢ ∂ₜ (S.energy xₜ) = 0
rw [equationOfMotion_iff_newtons_2nd_law _ _ hx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)⊢ ∂ₜ (S.energy xₜ) = 0 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)⊢ ∂ₜ (S.energy xₜ) = 0] at h S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)⊢ ∂ₜ (S.energy xₜ) = 0
funext t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)t:Time⊢ ∂ₜ (S.energy xₜ) t = 0 t
rw [energy_deriv _ _ hx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)t:Time⊢ (fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ) t = 0 t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)t:Time⊢ (fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ) t = 0 t] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)t:Time⊢ (fun t => ⟪∂ₜ xₜ t, S.m • ∂ₜ (∂ₜ xₜ) t + S.k • xₜ t⟫_ℝ) t = 0 t
simp [h, force_eq_linear] All goals completed! 🐙F.2. Energy conservation in terms of constant energy
We prove that the energy is constant for any trajectory satisfying the equation of motion.
lemma energy_conservation_of_equationOfMotion' (xₜ : Time → EuclideanSpace ℝ (Fin 1))
(hx : ContDiff ℝ ∞ xₜ)
(h : S.EquationOfMotion xₜ) (t : Time) : S.energy xₜ t = S.energy xₜ 0 := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt:Time⊢ S.energy xₜ t = S.energy xₜ 0
apply is_const_of_fderiv_eq_zero (𝕜 := ℝ) (energy_differentiable S xₜ hx) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt:Time⊢ ∀ (x : Time), fderiv ℝ (S.energy xₜ) x = 0
intro t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Time⊢ fderiv ℝ (S.energy xₜ) t = 0
ext p S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ (fderiv ℝ (S.energy xₜ) t) p = 0 p
rw [p.eq_one_smul, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ (fderiv ℝ (S.energy xₜ) t) (p.val • 1) = 0 (p.val • 1) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • 0 t = 0 (p.val • 1) map_smul, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • (fderiv ℝ (S.energy xₜ) t) 1 = 0 (p.val • 1) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • 0 t = 0 (p.val • 1) ← Time.deriv_eq, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • ∂ₜ (S.energy xₜ) t = 0 (p.val • 1) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • 0 t = 0 (p.val • 1)
S.energy_conservation_of_equationOfMotion xₜ hx h S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • 0 t = 0 (p.val • 1) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • 0 t = 0 (p.val • 1)] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜh:S.EquationOfMotion xₜt✝:Timet:Timep:Time⊢ p.val • 0 t = 0 (p.val • 1)
simp All goals completed! 🐙G. Hamiltonian formulation
We now turn to the Hamiltonian formulation of the harmonic oscillator. We define the canonical momentum, the Hamiltonian, and show that the equations of motion are equivalent to Hamilton's equations.
G.1. The canonical momentum
We define the canonical momentum as the gradient of the lagrangian with respect to the velocity.
G.1.1. Equality for the canonical momentum
An simple equality for the canonical momentum.
lemma toCanonicalMomentum_eq (t : Time) (x : EuclideanSpace ℝ (Fin 1))
(v : EuclideanSpace ℝ (Fin 1)) :
toCanonicalMomentum S t x v = S.m • v :=
gradient_lagrangian_velocity_eq S t x vG.2. The Hamiltonian
The hamiltonian is defined as a function of time, canonical momentum and position, as
H = ⟪p, v⟫ - L(t, x, v)
where v is a function of p and x through the canonical momentum.
G.2.1. Equality for the Hamiltonian
We prove a simple equality for the Hamiltonian, to help in computations.
lemma hamiltonian_eq :
hamiltonian S = fun _ p x => (1 / (2 : ℝ)) * (1 / S.m) * ⟪p, p⟫_ℝ +
(1 / (2 : ℝ)) * S.k * ⟪x, x⟫_ℝ := by S:HarmonicOscillator⊢ S.hamiltonian = fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ
funext t x p S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)⊢ S.hamiltonian t x p = 1 / 2 * (1 / S.m) * ⟪x, x⟫_ℝ + 1 / 2 * S.k * ⟪p, p⟫_ℝ
simp only [hamiltonian, toCanonicalMomentum, lagrangian_eq, one_div, LinearEquiv.coe_symm_mk',
inner_smul_right, inner_smul_left, map_inv₀, ringHom_apply] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)⊢ S.m⁻¹ * ⟪x, x⟫_ℝ - (2⁻¹ * S.m * (S.m⁻¹ * (S.m⁻¹ * ⟪x, x⟫_ℝ)) - 2⁻¹ * S.k * ⟪p, p⟫_ℝ) =
2⁻¹ * S.m⁻¹ * ⟪x, x⟫_ℝ + 2⁻¹ * S.k * ⟪p, p⟫_ℝ
field_simp S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)⊢ ⟪x, x⟫_ℝ * 2 - (⟪x, x⟫_ℝ - S.m * S.k * ⟪p, p⟫_ℝ) = ⟪x, x⟫_ℝ + S.m * S.k * ⟪p, p⟫_ℝ
ring All goals completed! 🐙G.2.2. Smoothness of the Hamiltonian
We show that the Hamiltonian is smooth in all its arguments.
@[fun_prop]
lemma hamiltonian_contDiff (n : WithTop ℕ∞) : ContDiff ℝ n ↿S.hamiltonian := by S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿S.hamiltonian
rw [hamiltonian_eq S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ] S:HarmonicOscillatorn:ℕ∞ω⊢ ContDiff ℝ n ↿fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ
fun_prop All goals completed! 🐙G.2.3. Gradients of the Hamiltonian
We now write down the gradients of the Hamiltonian with respect to the momentum and position.
lemma gradient_hamiltonian_position_eq (t : Time) (x : EuclideanSpace ℝ (Fin 1))
(p : EuclideanSpace ℝ (Fin 1)) :
gradient (hamiltonian S t p) x = S.k • x := by S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)⊢ gradient (S.hamiltonian t p) x = S.k • x
have h_eq : (fun y : EuclideanSpace ℝ (Fin 1) => hamiltonian S t p y) =
fun y => ((1 / (2 : ℝ)) * S.k) * ⟪y, y⟫_ℝ +
((1 / (2 : ℝ)) * (1 / S.m) * ⟪p, p⟫_ℝ) := by
funext y S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ S.hamiltonian t p y = 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (S.hamiltonian t p) x = S.k • x
simp only [hamiltonian_eq] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪y, y⟫_ℝ = 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (S.hamiltonian t p) x = S.k • x
ring S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (S.hamiltonian t p) x = S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (S.hamiltonian t p) x = S.k • x
change gradient (fun y : EuclideanSpace ℝ (Fin 1) => hamiltonian S t p y) x = S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (fun y => S.hamiltonian t p y) x = S.k • x
rw [h_eq, S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ) x = S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ (2 * (1 / 2 * S.k)) • x = S.k • x gradient_add_const', S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ gradient (fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ) x = S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ (2 * (1 / 2 * S.k)) • x = S.k • x gradient_const_mul_inner_self S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ (2 * (1 / 2 * S.k)) • x = S.k • x S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ (2 * (1 / 2 * S.k)) • x = S.k • x] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t p y) = fun y => 1 / 2 * S.k * ⟪y, y⟫_ℝ + 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ⊢ (2 * (1 / 2 * S.k)) • x = S.k • x
module All goals completed! 🐙
lemma gradient_hamiltonian_momentum_eq (t : Time) (x : EuclideanSpace ℝ (Fin 1))
(p : EuclideanSpace ℝ (Fin 1)) :
gradient (hamiltonian S t · x) p = (1 / S.m) • p := by S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)⊢ gradient (fun x_1 => S.hamiltonian t x_1 x) p = (1 / S.m) • p
have h_eq : (fun y : EuclideanSpace ℝ (Fin 1) => hamiltonian S t y x) =
fun y => ((1 / (2 : ℝ)) * (1 / S.m)) * ⟪y, y⟫_ℝ +
((1 / (2 : ℝ)) * S.k * ⟪x, x⟫_ℝ) := by
funext y S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)y:EuclideanSpace ℝ (Fin 1)⊢ S.hamiltonian t y x = 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun x_1 => S.hamiltonian t x_1 x) p = (1 / S.m) • p
simp only [hamiltonian_eq] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun x_1 => S.hamiltonian t x_1 x) p = (1 / S.m) • p S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun x_1 => S.hamiltonian t x_1 x) p = (1 / S.m) • p
change gradient (fun y : EuclideanSpace ℝ (Fin 1) => hamiltonian S t y x) p = (1 / S.m) • p S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun x_1 => S.hamiltonian t x_1 x) p = (1 / S.m) • p
rw [h_eq, S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ) p = (1 / S.m) • p S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * (1 / S.m))) • p = (1 / S.m) • p gradient_add_const', S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ gradient (fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ) p = (1 / S.m) • p S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * (1 / S.m))) • p = (1 / S.m) • p gradient_const_mul_inner_self S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * (1 / S.m))) • p = (1 / S.m) • p S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * (1 / S.m))) • p = (1 / S.m) • p] S:HarmonicOscillatort:Timex:EuclideanSpace ℝ (Fin 1)p:EuclideanSpace ℝ (Fin 1)h_eq:(fun y => S.hamiltonian t y x) = fun y => 1 / 2 * (1 / S.m) * ⟪y, y⟫_ℝ + 1 / 2 * S.k * ⟪x, x⟫_ℝ⊢ (2 * (1 / 2 * (1 / S.m))) • p = (1 / S.m) • p
module All goals completed! 🐙G.3. Relation between Hamiltonian and energy
We show that the Hamiltonian, when evaluated on any trajectory, is equal to the energy. This is independent of whether the trajectory satisfies the equations of motion or not.
lemma hamiltonian_eq_energy (xₜ : Time → EuclideanSpace ℝ (Fin 1)) :
(fun t => hamiltonian S t (toCanonicalMomentum S t (xₜ t) (∂ₜ xₜ t)) (xₜ t)) = energy S xₜ := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)⊢ (fun t => S.hamiltonian t ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) (xₜ t)) = S.energy xₜ
funext t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)t:Time⊢ S.hamiltonian t ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) (xₜ t) = S.energy xₜ t
rw [hamiltonian_eq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)t:Time⊢ (fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ) t
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) (xₜ t) =
S.energy xₜ t S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)t:Time⊢ (fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ) t
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) (xₜ t) =
S.energy xₜ t] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)t:Time⊢ (fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ) t
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) (xₜ t) =
S.energy xₜ t
unfold energy kineticEnergy potentialEnergy S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)t:Time⊢ (fun x p x_1 => 1 / 2 * (1 / S.m) * ⟪p, p⟫_ℝ + 1 / 2 * S.k * ⟪x_1, x_1⟫_ℝ) t
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) (xₜ t) =
1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ + (1 / 2) • S.k • ⟪xₜ t, xₜ t⟫_ℝ
simp only [toCanonicalMomentum_eq, inner_smul_left, inner_smul_right, smul_eq_mul, ringHom_apply] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)t:Time⊢ 1 / 2 * (1 / S.m) * (S.m * (S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ)) + 1 / 2 * S.k * ⟪xₜ t, xₜ t⟫_ℝ =
1 / 2 * S.m * ⟪∂ₜ xₜ t, ∂ₜ xₜ t⟫_ℝ + 1 / 2 * (S.k * ⟪xₜ t, xₜ t⟫_ℝ)
field_simp All goals completed! 🐙G.4. Hamilton equation operator
We define the operator on momentum-position phase-space whose vanishing is equivalent to Hamilton's equations.
G.5. Equation of motion if and only if Hamilton's equations
We show that the equation of motion is equivalent to Hamilton's equations, that is to the vanishing of the Hamilton equation operator.
lemma equationOfMotion_iff_hamiltonEqOp_eq_zero (xₜ : Time → EuclideanSpace ℝ (Fin 1))
(hx : ContDiff ℝ ∞ xₜ) : S.EquationOfMotion xₜ ↔
hamiltonEqOp S (fun t => S.toCanonicalMomentum t (xₜ t) (∂ₜ xₜ t)) xₜ = 0 := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔ S.hamiltonEqOp (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) xₜ = 0
rw [hamiltonEqOp, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) xₜ = 0 S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔
(∀ (t : Time), ∂ₜ xₜ t = gradient (fun x => S.hamiltonian t x (xₜ t)) ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))) ∧
∀ (t : Time),
∂ₜ (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) t =
-gradient (fun x => S.hamiltonian t ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) x) (xₜ t) hamiltonEqOp_eq_zero_iff_hamiltons_equations S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔
(∀ (t : Time), ∂ₜ xₜ t = gradient (fun x => S.hamiltonian t x (xₜ t)) ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))) ∧
∀ (t : Time),
∂ₜ (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) t =
-gradient (fun x => S.hamiltonian t ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) x) (xₜ t) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔
(∀ (t : Time), ∂ₜ xₜ t = gradient (fun x => S.hamiltonian t x (xₜ t)) ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))) ∧
∀ (t : Time),
∂ₜ (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) t =
-gradient (fun x => S.hamiltonian t ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) x) (xₜ t)] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔
(∀ (t : Time), ∂ₜ xₜ t = gradient (fun x => S.hamiltonian t x (xₜ t)) ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))) ∧
∀ (t : Time),
∂ₜ (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) t =
-gradient (fun x => S.hamiltonian t ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) x) (xₜ t)
simp [toCanonicalMomentum_eq, gradient_hamiltonian_momentum_eq, gradient_hamiltonian_position_eq] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ S.EquationOfMotion xₜ ↔ ∀ (t : Time), ∂ₜ (fun t => S.m • ∂ₜ xₜ t) t = -(S.k • xₜ t)
rw [equationOfMotion_iff_newtons_2nd_law _ _ hx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)) ↔ ∀ (t : Time), ∂ₜ (fun t => S.m • ∂ₜ xₜ t) t = -(S.k • xₜ t) S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)) ↔ ∀ (t : Time), ∂ₜ (fun t => S.m • ∂ₜ xₜ t) t = -(S.k • xₜ t)] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ (∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t)) ↔ ∀ (t : Time), ∂ₜ (fun t => S.m • ∂ₜ xₜ t) t = -(S.k • xₜ t)
simp [Time.deriv_smul _ S.m (deriv_differentiable_of_contDiff xₜ hx), force_eq_linear] All goals completed! 🐙H. Equivalences between the different formulations of the equations of motion
We show that the following are equivalent statements for a smooth trajectory xₜ:
The equation of motion holds. (aka the Euler-Lagrange equations hold.)
Newton's second law holds.
Hamilton's equations hold.
The variational principle for the action holds.
The Hamilton variational principle holds.
lemma equationOfMotion_tfae (xₜ : Time → EuclideanSpace ℝ (Fin 1)) (hx : ContDiff ℝ ∞ xₜ) :
List.TFAE [S.EquationOfMotion xₜ,
(∀ t, S.m • ∂ₜ (∂ₜ xₜ) t = force S (xₜ t)),
hamiltonEqOp S (fun t => S.toCanonicalMomentum t (xₜ t) (∂ₜ xₜ t)) xₜ = 0,
(δ (q':=xₜ), ∫ t, lagrangian S t (q' t) (fderiv ℝ q' t 1)) = 0,
(δ (pq':= fun t => (S.toCanonicalMomentum t (xₜ t) (∂ₜ xₜ t), xₜ t)),
∫ t, ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) = 0] := by S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t),
S.hamiltonEqOp (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t)) xₜ = 0,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(varGradient (fun pq' t => ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) fun t =>
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)) =
0].TFAE
rw [← equationOfMotion_iff_hamiltonEqOp_eq_zero, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, ∀ (t : Time), S.m • ∂ₜ (∂ₜ xₜ) t = S.force (xₜ t), S.EquationOfMotion xₜ,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(varGradient (fun pq' t => ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) fun t =>
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)) =
0].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(varGradient (fun pq' t => ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) fun t =>
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)) =
0].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ ← equationOfMotion_iff_newtons_2nd_law S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(varGradient (fun pq' t => ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) fun t =>
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)) =
0].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(varGradient (fun pq' t => ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) fun t =>
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)) =
0].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(varGradient (fun pq' t => ⟪(pq' t).1, ∂ₜ (Prod.snd ∘ pq') t⟫_ℝ - S.hamiltonian t (pq' t).1 (pq' t).2) fun t =>
((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)) =
0].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
rw [hamiltons_equations_varGradient, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
varGradient (fun q' t => S.lagrangian t (q' t) ((fderiv ℝ q' t) 1)) xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).1)
(fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).2) t) =
0].TFAEhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, eulerLagrangeOp S.lagrangian xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).1)
(fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).2) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ euler_lagrange_varGradient S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, eulerLagrangeOp S.lagrangian xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).1)
(fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).2) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, eulerLagrangeOp S.lagrangian xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).1)
(fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).2) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, S.EquationOfMotion xₜ, eulerLagrangeOp S.lagrangian xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).1)
(fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t).2) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
simp only [List.tfae_cons_self] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, eulerLagrangeOp S.lagrangian xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
rw [← gradLagrangian_eq_eulerLagrangeOp, S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.gradLagrangian xₜ = 0,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ ← equationOfMotion_iff_gradLagrangian_zero S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
simp only [List.tfae_cons_self] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ,
(fun t =>
ClassicalMechanics.hamiltonEqOp S.hamiltonian (fun t => (S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t))
(fun t => xₜ t) t) =
0].TFAEhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
erw [← equationOfMotion_iff_hamiltonEqOp_eq_zero S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ] S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ [S.EquationOfMotion xₜ, S.EquationOfMotion xₜ].TFAEhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
simp only [List.tfae_cons_self, List.tfae_singleton] hx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhq S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.lagrangianhp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
repeat fun_prop hp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => ((S.toCanonicalMomentum t (xₜ t)) (∂ₜ xₜ t), xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
simp [toCanonicalMomentum_eq] hp S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ fun t => (S.m • ∂ₜ xₜ t, xₜ t)hL S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ ↿S.hamiltonianhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜhx S:HarmonicOscillatorxₜ:Time → EuclideanSpace ℝ (Fin 1)hx:ContDiff ℝ ∞ xₜ⊢ ContDiff ℝ ∞ xₜ
repeat fun_prop All goals completed! 🐙