Finite element method in one dimension
DefinitionLength of a mesh element#✓fully proved
The length hᵢ = xᵢ₊₁ - xᵢ of the i-th element of the mesh.
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
Uses 1 · Used by 19
L² error estimate · Nodal values of the exact solution solve the Galerkin system · Uniqueness of the Galerkin solution · P1 functions are linear on each element · Linear map from nodal values to P1 functions · P1 functions interpolate their nodal values · Assembled stiffness matrix of the P1 method · Off-diagonal stiffness entry of an element · Tridiagonality of the stiffness matrix · Diagonal stiffness entry at an interior node · Element lengths are bounded by the mesh size · Mesh elements have positive lengthDefinitionSlope of a P1 function on a mesh element#✓fully proved
The slope (dᵢ₊₁ - dᵢ) / hᵢ on the i-th element of the P1 function with
nodal values d.
noncomputable def elementSlope (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) : ℝ :=
(d i.succ - d i.castSucc) / width P i
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 2 · Used by 14
L² error estimate · Nodal values of the exact solution solve the Galerkin system · Continuous piecewise linear function with given nodal values · P1 functions are linear on each element · P1 functions interpolate their nodal valuesDefinitionClamped ramp function of a mesh element#✓fully proved
The clamped ramp of the i-th element: 0 left of xᵢ, x - xᵢ on
[xᵢ, xᵢ₊₁], and hᵢ right of xᵢ₊₁.
noncomputable def ramp (i : Fin P.n) (x : ℝ) : ℝ :=
max (P.points i.castSucc) (min x (P.points i.succ)) - P.points i.castSucc
Uses 1 · Used by 4
DefinitionContinuous piecewise linear function with given nodal values#✓fully proved
The continuous piecewise linear (P1) function with nodal values d:
d₀ + ∑ᵢ slopeᵢ · rampᵢ(x). On [0, 1] it is linear on each element and
takes the value dⱼ at xⱼ; outside [0, 1] it is constant.
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
noncomputable def elementSlope (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) : ℝ :=
(d i.succ - d i.castSucc) / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:102
noncomputable def ramp (i : Fin P.n) (x : ℝ) : ℝ :=
max (P.points i.castSucc) (min x (P.points i.succ)) - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:107
Uses 3 · Used by 22
L² error estimate · Nodal interpolant of a function · Nodal values of the exact solution solve the Galerkin system · Characterization of membership in the P1 space · In one dimension the Galerkin solution is the nodal interpolant · P1 functions are linear on each element · Linear map from nodal values to P1 functions · P1 functions interpolate their nodal values · Energy error estimate for the P1 Galerkin solutionDefinitionHat function of a mesh node#✓fully proved
The hat function φⱼ of node j: the P1 function equal to 1 at xⱼ
and 0 at every other node.
noncomputable def hat (j : Fin (P.n + 1)) : ℝ → ℝ :=
p1 P (Pi.single j 1)
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 2 · Used by 4
DefinitionNodal interpolant of a function#✓fully proved
The nodal interpolant I_h u: the P1 function with nodal values
u(xⱼ).
noncomputable def interp (u : ℝ → ℝ) : ℝ → ℝ :=
p1 P fun j => u (P.points j)
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 2 · Used by 4
DefinitionLinear map from nodal values to P1 functions#✓fully proved
p1 as a linear map from nodal values to functions.
MathlibExt.Analysis.ODE.FiniteElement1D.p1Map · 16 lines
noncomputable def p1Map : (Fin (P.n + 1) → ℝ) →ₗ[ℝ] ℝ → ℝ where
toFun := p1 P
map_add' c d := by
funext x
simp only [p1, elementSlope, Pi.add_apply]
rw [add_add_add_comm, ← Finset.sum_add_distrib]
congr 1
refine Finset.sum_congr rfl fun i _ => ?_
ring
map_smul' a d := by
funext x
simp only [p1, elementSlope, Pi.smul_apply, smul_eq_mul, RingHom.id_apply]
rw [mul_add, Finset.mul_sum]
congr 1
refine Finset.sum_congr rfl fun i _ => ?_
ring
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
DefinitionNodal vectors with zero boundary values#✓fully proved
Nodal vectors with zero boundary values d₀ = dₙ = 0.
def dirichletNodal : Submodule ℝ (Fin (P.n + 1) → ℝ) :=
LinearMap.ker (LinearMap.proj 0) ⊓ LinearMap.ker (LinearMap.proj (Fin.last P.n))
Uses 1 · Used by 1
DefinitionP1 finite element space with zero boundary values#✓fully proved
The P1 finite element space V_h with zero boundary values: the image under
p1Map of the nodal vectors vanishing at both ends.
noncomputable def p1Space : Submodule ℝ (ℝ → ℝ) :=
(dirichletNodal P).map (p1Map P)
def dirichletNodal : Submodule ℝ (Fin (P.n + 1) → ℝ) :=
LinearMap.ker (LinearMap.proj 0) ⊓ LinearMap.ker (LinearMap.proj (Fin.last P.n))
MathlibExt/Analysis/ODE/FiniteElement1D.lean:145
noncomputable def p1Map : (Fin (P.n + 1) → ℝ) →ₗ[ℝ] ℝ → ℝ where
toFun := p1 P
map_add' c d := by
funext x
simp only [p1, elementSlope, Pi.add_apply]
rw [add_add_add_comm, ← Finset.sum_add_distrib]
congr 1
refine Finset.sum_congr rfl fun i _ => ?_
ring
map_smul' a d := by
funext x
simp only [p1, elementSlope, Pi.smul_apply, smul_eq_mul, RingHom.id_apply]
⋯
MathlibExt/Analysis/ODE/FiniteElement1D.lean:127
Uses 3 · Used by 5
DefinitionEnergy form of the equation \(-u'' = f\)#✓fully proved
The energy form a(u, v) = ∫₀¹ u'(x) v'(x) dx of -u'' = f. For a P1
function, deriv is junk at the mesh nodes, a null set.
Used by 12
DefinitionElement vector of the stiffness assembly#✓fully proved
The i-th element vector eᵢ = δ_{i+1} - δᵢ of the assembly.
noncomputable def elementVector (i : Fin P.n) : Fin (P.n + 1) → ℝ :=
Pi.single i.succ 1 - Pi.single i.castSucc 1
Uses 1 · Used by 6
DefinitionAssembled stiffness matrix of the P1 method#✓fully proved
The assembled stiffness matrix K = ∑ᵢ (1 / hᵢ) eᵢ eᵢᵀ on all nodes:
each element contributes (1 / hᵢ) [[1, -1], [-1, 1]] at nodes i, i + 1.
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
noncomputable def elementVector (i : Fin P.n) : Fin (P.n + 1) → ℝ :=
Pi.single i.succ 1 - Pi.single i.castSucc 1
MathlibExt/Analysis/ODE/FiniteElement1D.lean:159
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 3 · Used by 8
DefinitionLoad vector of the P1 method#✓fully proved
The load vector Fⱼ = ∫₀¹ f φⱼ.
noncomputable def load (f : ℝ → ℝ) (j : Fin (P.n + 1)) : ℝ :=
∫ x in (0 : ℝ)..1, f x * hat P j x
noncomputable def hat (j : Fin (P.n + 1)) : ℝ → ℝ :=
p1 P (Pi.single j 1)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:118
Uses 2 · Used by 3
StructureClassical solution of the Dirichlet problem \(-u'' = f\)#✓fully proved
u is a classical solution of -u'' = f on (0, 1) with
u(0) = u(1) = 0. We ask u to be C² on all of ℝ, which is no loss for
the interval problem (a C² function on [0, 1] extends), and f to be continuous.
The equation is stated on the open interval, as in the Dirichlet problem: requiring it
at the endpoints without regularity of f would be a genuine strengthening. With f
continuous, endpoint equality follows by continuity (eq_Icc), and the integral proofs
use that derived version.
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
Used by 10
L² error estimate · Nodal values of the exact solution solve the Galerkin system · In one dimension the Galerkin solution is the nodal interpolant · Energy error estimate for the P1 Galerkin solutionTheoremClassical solutions satisfy the equation on the closed interval#✓fully proved
Endpoint equality, derived from the open-interval equation by continuity of
-u'' and f: the two sides agree on (0, 1), hence on its closure [0, 1].
theorem IsClassicalSolution.eq_Icc {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{x : ℝ} (hx : x ∈ Set.Icc (0 : ℝ) 1) : -deriv (deriv u) x = f x
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
DefinitionSolution of the Galerkin system#✓fully proved
The coefficient vector c solves the Galerkin system: zero boundary
values and (K c)ⱼ = Fⱼ at every interior node j. The Galerkin solution is
u_h = p1 P c.
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:164
noncomputable def load (f : ℝ → ℝ) (j : Fin (P.n + 1)) : ℝ :=
∫ x in (0 : ℝ)..1, f x * hat P j x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:168
Uses 3 · Used by 8
L² error estimate · Nodal values of the exact solution solve the Galerkin system · Uniqueness of the Galerkin solution · In one dimension the Galerkin solution is the nodal interpolant · Energy error estimate for the P1 Galerkin solutionThe P1 functions
TheoremMesh elements have positive length#✓fully proved
Every element has positive length.
theorem width_pos (i : Fin P.n) : 0 < width P i
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 2 · Used by 6
TheoremElement lengths are bounded by the mesh size#✓fully proved
Every element length is at most the mesh size h.
theorem width_le_mesh (i : Fin P.n) : width P i ≤ P.mesh
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 3 · Used by 2
L² error estimateTheoremP1 functions are linear on each element#✓fully proved
On the i-th element, p1 P d is the linear function through
(xᵢ, dᵢ) with slope slopeᵢ = elementSlope P d i.
theorem p1_eq_of_mem_Icc (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) {x : ℝ}
(hx : x ∈ Set.Icc (P.points i.castSucc) (P.points i.succ)) :
p1 P d x = d i.castSucc + elementSlope P d i * (x - P.points i.castSucc)
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
noncomputable def elementSlope (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) : ℝ :=
(d i.succ - d i.castSucc) / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:102
Uses 6 · Used by 4
TheoremP1 functions interpolate their nodal values#✓fully proved
p1 P d interpolates the nodal values.
theorem p1_points (d : Fin (P.n + 1) → ℝ) (j : Fin (P.n + 1)) :
p1 P d (P.points j) = d j
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 6 · Used by 2
TheoremContinuity of P1 functions#✓fully proved
P1 functions are continuous.
theorem continuous_p1 (d : Fin (P.n + 1) → ℝ) : Continuous (p1 P d)
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 4 · Used by 3
TheoremDerivative of a P1 function inside an element#✓fully proved
Inside an element, p1 P d has derivative slopeᵢ.
theorem hasDerivAt_p1 (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) {x : ℝ}
(hx : x ∈ Set.Ioo (P.points i.castSucc) (P.points i.succ)) :
HasDerivAt (p1 P d) (elementSlope P d i) x
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
noncomputable def elementSlope (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) : ℝ :=
(d i.succ - d i.castSucc) / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:102
Uses 4 · Used by 4
TheoremIntegral over the unit interval as a sum over elements#✓fully proved
An integral over [0, 1] is the sum of the integrals over the elements.
theorem integral_eq_sum (g : ℝ → ℝ)
(hg : ∀ i : Fin P.n, IntervalIntegrable g volume (P.points i.castSucc) (P.points i.succ)) :
∫ x in (0 : ℝ)..1, g x = ∑ i : Fin P.n, ∫ x in P.points i.castSucc..P.points i.succ, g x
TheoremEnergy pairing with a P1 function via nodal differences#✓fully proved
The key identity of the 1D P1 method: for w continuous on each element,
differentiable inside it, and with integrable derivative there,
a(w, p1 d) = ∑ᵢ slopeᵢ(d) (w(xᵢ₊₁) - w(xᵢ)).
theorem energy_p1 (w : ℝ → ℝ)
(hcont : ∀ i : Fin P.n, ContinuousOn w (Set.Icc (P.points i.castSucc) (P.points i.succ)))
(hdiff : ∀ i : Fin P.n, ∀ x ∈ Set.Ioo (P.points i.castSucc) (P.points i.succ),
DifferentiableAt ℝ w x)
(hint : ∀ i : Fin P.n,
IntervalIntegrable (deriv w) volume (P.points i.castSucc) (P.points i.succ))
(d : Fin (P.n + 1) → ℝ) :
energy w (p1 P d) =
∑ i, elementSlope P d i * (w (P.points i.succ) - w (P.points i.castSucc))
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
noncomputable def elementSlope (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) : ℝ :=
(d i.succ - d i.castSucc) / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:102
Uses 6 · Used by 4
Weak form, stiffness matrix, Galerkin orthogonality
TheoremCharacterization of membership in the P1 space#✓fully proved
Membership in the P1 space: v = p1 P d for nodal values d with
d₀ = dₙ = 0.
theorem mem_p1Space {v : ℝ → ℝ} :
v ∈ p1Space P ↔ ∃ d, d 0 = 0 ∧ d (Fin.last P.n) = 0 ∧ p1 P d = v
noncomputable def p1Space : Submodule ℝ (ℝ → ℝ) :=
(dirichletNodal P).map (p1Map P)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:150
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 4 · Used by 4
TheoremInterior hat functions lie in the P1 space#✓fully proved
The hat function of an interior node lies in the P1 space.
theorem hat_mem_p1Space {j : Fin (P.n + 1)} (h0 : j ≠ 0) (hl : j ≠ Fin.last P.n) :
hat P j ∈ p1Space P
noncomputable def hat (j : Fin (P.n + 1)) : ℝ → ℝ :=
p1 P (Pi.single j 1)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:118
noncomputable def p1Space : Submodule ℝ (ℝ → ℝ) :=
(dirichletNodal P).map (p1Map P)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:150
Uses 5 · Used by 1
TheoremWeak form of the classical solution for \(C^1\) test functions#✓fully proved
The weak form for C¹ test functions vanishing at 0 and 1:
∫₀¹ u' v' = ∫₀¹ f v.
theorem energy_eq_integral_mul_of_contDiff {f u v : ℝ → ℝ} (hu : IsClassicalSolution f u)
(hv : ContDiff ℝ 1 v) (hv0 : v 0 = 0) (hv1 : v 1 = 0) :
energy u v = ∫ x in (0 : ℝ)..1, f x * v x
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
TheoremWeak form of the classical solution for P1 test functions#✓fully proved
The weak form for P1 test functions: ∫₀¹ u' v_h' = ∫₀¹ f v_h.
theorem energy_eq_integral_mul_of_mem_p1Space {f u v : ℝ → ℝ} (hu : IsClassicalSolution f u)
(hv : v ∈ p1Space P) :
energy u v = ∫ x in (0 : ℝ)..1, f x * v x
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
noncomputable def p1Space : Submodule ℝ (ℝ → ℝ) :=
(dirichletNodal P).map (p1Map P)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:150
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
Uses 13 · Used by 1
TheoremEnergy form of two P1 functions#✓fully proved
The energy form of two P1 functions:
a(p1 c, p1 d) = ∑ᵢ (cᵢ₊₁ - cᵢ)(dᵢ₊₁ - dᵢ) / hᵢ.
theorem energy_p1_p1 (c d : Fin (P.n + 1) → ℝ) :
energy (p1 P c) (p1 P d) =
∑ i, (c i.succ - c i.castSucc) * (d i.succ - d i.castSucc) / width P i
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 9 · Used by 1
TheoremQuadratic form of the stiffness matrix#✓fully proved
The quadratic form of the stiffness matrix:
dᵀ K c = ∑ᵢ (cᵢ₊₁ - cᵢ)(dᵢ₊₁ - dᵢ) / hᵢ.
theorem dotProduct_stiffness_mulVec (c d : Fin (P.n + 1) → ℝ) :
d ⬝ᵥ (stiffness P).mulVec c =
∑ i, (c i.succ - c i.castSucc) * (d i.succ - d i.castSucc) / width P i
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:164
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 4 · Used by 2
TheoremStiffness matrix is the Gram matrix of the hat functions#✓fully proved
The stiffness matrix is the Gram matrix of the hat functions:
a(φⱼ, φₖ) = Kⱼₖ.
theorem energy_hat_hat (j k : Fin (P.n + 1)) :
energy (hat P j) (hat P k) = stiffness P j k
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def hat (j : Fin (P.n + 1)) : ℝ → ℝ :=
p1 P (Pi.single j 1)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:118
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:164
TheoremOff-diagonal stiffness entry of an element#✓fully proved
The off-diagonal entry of an element: K_{i, i+1} = -1 / hᵢ.
theorem stiffness_castSucc_succ (i : Fin P.n) :
stiffness P i.castSucc i.succ = -(width P i)⁻¹
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:164
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 4
TheoremDiagonal stiffness entry at an interior node#✓fully proved
The diagonal entry at an interior node xⱼ shared by consecutive
elements i and j: K = 1 / hᵢ + 1 / hⱼ.
theorem stiffness_succ_succ {i j : Fin P.n} (hij : i.succ = j.castSucc) :
stiffness P i.succ i.succ = (width P i)⁻¹ + (width P j)⁻¹
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:164
noncomputable def width (i : Fin P.n) : ℝ :=
P.points i.succ - P.points i.castSucc
MathlibExt/Analysis/ODE/FiniteElement1D.lean:97
Uses 4
TheoremTridiagonality of the stiffness matrix#✓fully proved
Entries between nodes two or more apart vanish (tridiagonality).
theorem stiffness_eq_zero {j k : Fin (P.n + 1)} (hjk : (j : ℕ) + 2 ≤ k) :
stiffness P j k = 0
noncomputable def stiffness : Matrix (Fin (P.n + 1)) (Fin (P.n + 1)) ℝ :=
fun j k => ∑ i, elementVector P i j * elementVector P i k / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:164
Uses 4
TheoremNodal values of the exact solution solve the Galerkin system#✓fully proved
The nodal values of the exact solution solve the Galerkin system.
theorem isGalerkinSolution_nodal {f u : ℝ → ℝ} (hu : IsClassicalSolution f u) :
IsGalerkinSolution P f fun j => u (P.points j)
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
Uses 14 · Used by 3
TheoremUniqueness of the Galerkin solution#✓fully proved
The Galerkin system has at most one solution (K is positive definite on
nodal vectors with zero boundary values).
theorem isGalerkinSolution_unique {f : ℝ → ℝ} {c c' : Fin (P.n + 1) → ℝ}
(hc : IsGalerkinSolution P f c) (hc' : IsGalerkinSolution P f c') : c = c'
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
Uses 7 · Used by 3
TheoremIn one dimension the Galerkin solution is the nodal interpolant#✓fully proved
In one dimension the P1 Galerkin solution is the nodal interpolant of the
exact solution: u_h = I_h u.
theorem p1_eq_interp_of_isGalerkinSolution {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{c : Fin (P.n + 1) → ℝ} (hc : IsGalerkinSolution P f c) :
p1 P c = interp P u
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
noncomputable def interp (u : ℝ → ℝ) : ℝ → ℝ :=
p1 P fun j => u (P.points j)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:123
Uses 7 · Used by 2
L² error estimateTheoremGalerkin orthogonality#✓fully proved
a(u - u_h, v_h) = 0 for every v_h ∈ V_h.
theorem galerkin_orthogonality {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{c : Fin (P.n + 1) → ℝ} (hc : IsGalerkinSolution P f c) {v : ℝ → ℝ}
(hv : v ∈ p1Space P) :
energy (u - p1 P c) v = 0
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
noncomputable def p1Space : Submodule ℝ (ℝ → ℝ) :=
(dirichletNodal P).map (p1Map P)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:150
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 14
TheoremElement-wise energy of a function minus a P1 function#✓fully proved
Element-wise form of the energy of u - p1 d for a C² function u:
a(u - p1 d, u - p1 d) = ∑ᵢ ∫_{xᵢ}^{xᵢ₊₁} (u' - slopeᵢ(d))².
theorem energy_sub_p1_self {u : ℝ → ℝ} (hu : ContDiff ℝ 2 u)
(d : Fin (P.n + 1) → ℝ) :
energy (u - p1 P d) (u - p1 P d) = ∑ i, ∫ x in P.points i.castSucc..P.points i.succ,
(deriv u x - elementSlope P d i) ^ 2
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
noncomputable def elementSlope (d : Fin (P.n + 1) → ℝ) (i : Fin P.n) : ℝ :=
(d i.succ - d i.castSucc) / width P i
MathlibExt/Analysis/ODE/FiniteElement1D.lean:102
Uses 6 · Used by 2
TheoremBest approximation#✓fully proved
Best approximation (Céa's lemma for the symmetric energy form, with
constant 1): ‖u - u_h‖_a ≤ ‖u - v_h‖_a for every v_h ∈ V_h.
theorem energy_sub_galerkin_le {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{c : Fin (P.n + 1) → ℝ} (hc : IsGalerkinSolution P f c) {v : ℝ → ℝ}
(hv : v ∈ p1Space P) :
energy (u - p1 P c) (u - p1 P c) ≤ energy (u - v) (u - v)
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
noncomputable def p1Space : Submodule ℝ (ℝ → ℝ) :=
(dirichletNodal P).map (p1Map P)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:150
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 13
Error estimates
TheoremWirtinger's inequality on an interval#✓fully proved
Wirtinger's inequality on [a, b]: a C¹ function vanishing at a and
b satisfies ∫ₐᵇ g² ≤ ((b - a) / π)² ∫ₐᵇ (g')².
theorem integral_sq_le_of_eq_zero {g : ℝ → ℝ} {a b : ℝ} (hab : a < b) (hg : ContDiff ℝ 1 g)
(ha : g a = 0) (hb : g b = 0) :
∫ x in a..b, g x ^ 2 ≤ ((b - a) / Real.pi) ^ 2 * ∫ x in a..b, deriv g x ^ 2
Uses 1 · Used by 2
TheoremElement estimate for \(C^2\) functions vanishing at both ends#✓fully proved
The element estimate: a C² function vanishing at a and b satisfies
∫ₐᵇ (g')² ≤ ((b - a) / π)² ∫ₐᵇ (g'')².
theorem integral_deriv_sq_le_of_eq_zero {g : ℝ → ℝ} {a b : ℝ} (hab : a < b)
(hg : ContDiff ℝ 2 g) (ha : g a = 0) (hb : g b = 0) :
∫ x in a..b, deriv g x ^ 2 ≤
((b - a) / Real.pi) ^ 2 * ∫ x in a..b, deriv (deriv g) x ^ 2
Uses 1 · Used by 2
L² error estimateTheoremInterpolation estimate#✓fully proved
‖u - I_h u‖_a² ≤ (h / π)² ‖u''‖²_{L²(0,1)},
with h the mesh size.
theorem energy_sub_interp_le {u : ℝ → ℝ} (hu : ContDiff ℝ 2 u) :
energy (u - interp P u) (u - interp P u) ≤
(P.mesh / Real.pi) ^ 2 * ∫ x in (0 : ℝ)..1, deriv (deriv u) x ^ 2
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def interp (u : ℝ → ℝ) : ℝ → ℝ :=
p1 P fun j => u (P.points j)
MathlibExt/Analysis/ODE/FiniteElement1D.lean:123
Uses 12 · Used by 1
TheoremEnergy error estimate#✓fully proved
‖u - u_h‖_a² ≤ (h / π)² ‖f‖²_{L²(0,1)}, so the
energy error is O(h).
theorem energy_sub_galerkin_le_mesh {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{c : Fin (P.n + 1) → ℝ} (hc : IsGalerkinSolution P f c) :
energy (u - p1 P c) (u - p1 P c) ≤
(P.mesh / Real.pi) ^ 2 * ∫ x in (0 : ℝ)..1, f x ^ 2
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 10 · Used by 1
TheoremEnergy error estimate for the P1 Galerkin solution#✓fully proved
The energy error estimate in norm form:
‖u - u_h‖_a ≤ (h / π) ‖f‖_{L²(0,1)}.
theorem sqrt_energy_sub_galerkin_le_mesh {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{c : Fin (P.n + 1) → ℝ} (hc : IsGalerkinSolution P f c) :
√(energy (u - p1 P c) (u - p1 P c)) ≤
P.mesh / Real.pi * √(∫ x in (0 : ℝ)..1, f x ^ 2)
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
noncomputable def energy (u v : ℝ → ℝ) : ℝ :=
∫ x in (0 : ℝ)..1, deriv u x * deriv v x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:155
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
TheoremL² error estimate#✓fully proved
‖u - u_h‖²_{L²(0,1)} ≤ (h / π)⁴ ‖f‖²_{L²(0,1)},
so the L² error is O(h²). The proof uses nodal exactness and Wirtinger's
inequality on each element, not the Aubin–Nitsche duality argument.
theorem integral_sq_sub_galerkin_le_mesh {f u : ℝ → ℝ} (hu : IsClassicalSolution f u)
{c : Fin (P.n + 1) → ℝ} (hc : IsGalerkinSolution P f c) :
∫ x in (0 : ℝ)..1, (u x - p1 P c x) ^ 2 ≤
(P.mesh / Real.pi) ^ 4 * ∫ x in (0 : ℝ)..1, f x ^ 2
structure IsClassicalSolution (f u : ℝ → ℝ) : Prop where
contDiff : ContDiff ℝ 2 u
f_cont : Continuous f
zero_left : u 0 = 0
zero_right : u 1 = 0
eq : ∀ x ∈ Set.Ioo (0 : ℝ) 1, -deriv (deriv u) x = f x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:178
def IsGalerkinSolution (f : ℝ → ℝ) (c : Fin (P.n + 1) → ℝ) : Prop :=
c 0 = 0 ∧ c (Fin.last P.n) = 0 ∧
∀ j, j ≠ 0 → j ≠ Fin.last P.n → (stiffness P).mulVec c j = load P f j
MathlibExt/Analysis/ODE/FiniteElement1D.lean:201
noncomputable def p1 (d : Fin (P.n + 1) → ℝ) (x : ℝ) : ℝ :=
d 0 + ∑ i, elementSlope P d i * ramp P i x
MathlibExt/Analysis/ODE/FiniteElement1D.lean:113
Uses 17
Loading dependency explorer…
The dependency explorer needs JavaScript and its graph data.