LeanFun RevOLVER

2.4 Interpolation at Chebyshev points

Interpolation constructs a polynomial from sampled values. On the Chebyshev extrema grid, a discrete cosine transform gives its coefficients, while the barycentric formula evaluates it directly from the samples.

2.4.1 Interpolation and the cosine grid

For distinct nodes \(x_0,\ldots ,x_N\), the cardinal polynomials are \(\ell _j(X)=\prod _{i\ne j}(X-x_i)/(x_j-x_i)\). Their values at the nodes are \(\ell _j(x_i)=\delta _{ij}\), so \(\sum _j f(x_j)\ell _j\) interpolates the data (Theorem 2.4.15). We now choose the cosine grid.

Definition 2.4.1 Classical Chebyshev cosine nodes
✓ 🤖
#

For a positive natural order \(N\) and a natural angular index \(j\), define \(x_{N,j}=\cos (j\pi /N)\). The extrema grid consists of \(0\le j\le N\). Reference: [ATAP, Chapter 4].

Lean Formalisation
def Polynomial.Chebyshev.classicalNode (N : { n // 0 < n }) (j : ℕ) : ℝ
Lean definition
/-- Classical cosine nodes for positive order, with arbitrary natural angular index. -/
noncomputable def classicalNode (N : {n : ℕ // 0 < n}) (j : ℕ) : ℝ := node N.val j
source
Definition 2.4.2 Finite extrema grid
✓ 🤖
#

For \(N\ge 0\), index the grid by \(0\le j\le N\). When \(N{\gt}0\) its points are \(x_{N,j}=\cos (j\pi /N)\). For \(N=0\) there is one node, \(x_{0,0}=1\).

Lean Formalisation
def Polynomial.Chebyshev.extremaGridNode (N : ℕ) (j : Fin (N + 1)) : ℝ
Lean definition
/-- Finite extrema grid, with the separate singleton at `1` for order zero. -/
noncomputable def extremaGridNode (N : ℕ) (j : Fin (N + 1)) : ℝ :=
  if h : N = 0 then 1 else classicalNode ⟨N, Nat.pos_of_ne_zero h⟩ j
source
Definition 2.4.3 Classical extrema cardinal polynomials
✓ 🤖

For a finite-grid index \(j\), let \(\ell _{N,j}\) be its classical Lagrange cardinal polynomial. At order zero it is the constant polynomial \(1\). Reference: [ATAP, Chapter 4].

Lean Formalisation
def Polynomial.Chebyshev.extremaCardinal (N : ℕ) (j : Fin (N + 1)) : Polynomial ℂ
Lean definition
/-- Classical cardinal polynomial on the finite extrema grid (ATAP Chapter 4).
For the singleton grid it is the constant one. -/
@[expose] noncomputable def extremaCardinal (N : ℕ) (j : Fin (N + 1)) : ℂ[X] :=
  if h : N = 0 then 1 else
    Lagrange.classicalBasis (Finset.range (N + 1))
      (fun i ↦ (classicalNode ⟨N, Nat.pos_of_ne_zero h⟩ i : ℂ)) j
      (Lagrange.BasisInput.of_injOn (Complex.ofReal_injective.comp_injOn (strictAntiOn_classicalNode ⟨N,Nat.pos_of_ne_zero h⟩).injOn) (Finset.mem_range.mpr j.isLt))
source

For positive order the cardinal polynomials are the classical Lagrange products; for order zero the single polynomial is \(1\). For every order, \(\ell _{N,i}(x_{N,j})=\delta _{ij}\).

Lean Formalisation
theorem Polynomial.Chebyshev.extremaCardinal_zero (j : Fin 1) : Polynomial.Chebyshev.extremaCardinal 0 j = 1
Lean proof
/-- Singleton cardinal polynomial. -/
theorem extremaCardinal_zero (j : Fin 1) : extremaCardinal 0 j = 1 := by
  simp [extremaCardinal]
source
Definition 2.4.5 Chebyshev-extrema interpolant
✓ 🤖

For \(N\ge 1\), let \(I_Nf\in \mathbb {C}[X]\) be the Lagrange interpolant of \(f:\mathbb {R}\to \mathbb {C}\) at the \(N+1\) distinct Chebyshev extrema \(x_j=\cos (j\pi /N)\), \(0\le j\le N\). For \(N=0\), define \(I_0f\) to be the constant polynomial \(f(1)\).

Reference: [ATAP, Chapters 4 and 8].

Lean Formalisation
def Polynomial.Chebyshev.extremaInterpolant (N : ℕ) (f : ℝ → ℂ) : Polynomial ℂ
Lean definition
/-- Interpolation at positive-order extrema, with the separate singleton at `1`
for order zero (ATAP Chapters 4 and 8). -/
@[expose] noncomputable def extremaInterpolant (N : ℕ) (f : ℝ → ℂ) : ℂ[X] :=
  if h : N = 0 then Polynomial.C (f 1) else
    Lagrange.classicalInterpolate (Finset.range (N + 1))
      (fun j ↦ (classicalNode ⟨N, Nat.pos_of_ne_zero h⟩ j : ℂ))
      ⟨Complex.ofReal_injective.comp_injOn (strictAntiOn_classicalNode ⟨N,Nat.pos_of_ne_zero h⟩).injOn⟩ (fun j ↦ f (classicalNode ⟨N, Nat.pos_of_ne_zero h⟩ j))
source

For \(N\ge 1\) and \(0\le j\le N\), \(I_Nf(x_j)=f(x_j)\), and \(I_Nf\) has degree at most \(N\).

Reference: [ATAP, Chapter 4].

Lean Formalisation
theorem Polynomial.Chebyshev.eval_extremaInterpolant_classicalNode (N : { n // 0 < n }) (f : ℝ → ℂ) (j : Fin (↑N + 1)) :
  Polynomial.eval (↑(Polynomial.Chebyshev.classicalNode N ↑j)) (Polynomial.Chebyshev.extremaInterpolant (↑N) f) =
    f (Polynomial.Chebyshev.classicalNode N ↑j)
Lean proof
/-- Interpolation at a node on the classical positive-order grid. -/
theorem eval_extremaInterpolant_classicalNode (N : {n : ℕ // 0 < n})
    (f : ℝ → ℂ) (j : Fin (N.val + 1)) :
    (extremaInterpolant N.val f).eval (classicalNode N j : ℂ) = f (classicalNode N j) := by
  rw [extremaInterpolant_positive N]
  exact Lagrange.eval_classicalInterpolate
    (s := Finset.range (N.val+1)) (v := fun k ↦ (classicalNode N k : ℂ))
    _ _ ⟨j.val, Finset.mem_range.mpr j.isLt⟩
source
Lagrange products and interpolation domains

The nodes obey the displayed cosine formula and lie in \([-1,1]\). They are strictly decreasing for \(0\le j\le N\), with endpoints \(1\) and \(-1\).

Lean Formalisation
theorem Polynomial.Chebyshev.classicalNode_apply (N : { n // 0 < n }) (j : ℕ) :
  Polynomial.Chebyshev.classicalNode N j = Real.cos (↑j * Real.pi / ↑↑N)
Lean proof
/-- Cosine formula on the positive-order domain. -/
theorem classicalNode_apply (N : {n : ℕ // 0 < n}) (j : ℕ) :
    classicalNode N j = Real.cos (j * Real.pi / N.val) := rfl
source

For \(N=0\), \(x_{0,0}=1\); for \(N{\gt}0\), \(x_{N,j}=\cos (j\pi /N)\). All grid points lie in \([-1,1]\) and are pairwise distinct.

Lean Formalisation
theorem Polynomial.Chebyshev.extremaGridNode_zero (j : Fin 1) : Polynomial.Chebyshev.extremaGridNode 0 j = 1
Lean proof
/-- The order-zero grid is the singleton `1`. -/
theorem extremaGridNode_zero (j : Fin 1) : extremaGridNode 0 j = 1 := by
  simp [extremaGridNode]
source
Theorem 2.4.9 Extrema-interpolant characterisation
✓ 🤖

For positive order, \(I_Nf\) is classical interpolation on the cosine grid. For order zero, \(I_0f\) is exactly the constant polynomial \(f(1)\).

Lean Formalisation
theorem Polynomial.Chebyshev.extremaInterpolant_positive (N : { n // 0 < n }) (f : ℝ → ℂ) :
  Polynomial.Chebyshev.extremaInterpolant (↑N) f =
    Lagrange.classicalInterpolate (Finset.range (↑N + 1)) (fun j => ↑(Polynomial.Chebyshev.classicalNode N j)) ⋯
      fun j => f (Polynomial.Chebyshev.classicalNode N j)
Lean proof
/-- Positive-order extrema interpolation is classical interpolation at cosine nodes. -/
theorem extremaInterpolant_positive (N : {n : ℕ // 0 < n}) (f : ℝ → ℂ) :
    extremaInterpolant N.val f = Lagrange.classicalInterpolate (Finset.range (N.val + 1))
      (fun j ↦ (classicalNode N j : ℂ)) ⟨Complex.ofReal_injective.comp_injOn (strictAntiOn_classicalNode N).injOn⟩
      (fun j ↦ f (classicalNode N j)) := by
  simp only [extremaInterpolant, dite_eq_right (Nat.ne_of_gt N.property)]
source
Definition 2.4.10 Domain of the Lagrange products
✓ 🤖
#

For a finite index set \(s\) and field-valued nodes \(v\), define the admissible indices to be those \(i\) satisfying \(v_i\ne v_j\) for every \(j\in s\setminus \{ i\} \). An admissible index need not belong to \(s\).

Lean Formalisation
inductive Lagrange.BasisInput.{u_1, u_2} {F : Type u_1} {ι : Type u_2} [DecidableEq ι] (s : Finset ι) (v : ι → F) (i : ι) : Prop
Lean definition
/-- Precisely the nonzero denominators of a normalized nodal product. -/
structure BasisInput (s : Finset ι) (v : ι → F) (i : ι) : Prop where
  separated : ∀ j ∈ s.erase i, v i ≠ v j
source
Theorem 2.4.11 Nonvanishing of Lagrange denominators
✓ 🤖

If the nodes \(v_i\) are distinct on \(s\), then every \(i\in s\) is admissible: \(v_i-v_j\ne 0\) for \(j\in s\setminus \{ i\} \). For identity nodes on a finite subset \(s\) of a field, every field element \(x\) is admissible, since \(x-y\ne 0\) for \(y\in s\setminus \{ x\} \); this includes \(x\notin s\).

Lean Formalisation
theorem Lagrange.BasisInput.of_injOn.{u_1, u_2} {F : Type u_1} {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → F}
  (hv : Set.InjOn v ↑s) {i : ι} (hi : i ∈ s) : Lagrange.BasisInput s v i
Lean proof
/-- Distinct interpolation nodes supply classical basis inputs. -/
theorem BasisInput.of_injOn {s : Finset ι} {v : ι → F}
    (hv : Set.InjOn v s) {i : ι} (hi : i ∈ s) : BasisInput s v i :=
  ⟨fun _j hj h ↦ (Finset.mem_erase.mp hj).1 (hv (Finset.mem_erase.mp hj).2 hi h.symm)⟩
source
Definition 2.4.12 Classical Lagrange polynomials
✓ 🤖
#

For an admissible index \(i\) of Definition 2.4.10, define \(\ell _i(X)=\prod _{j\in s\setminus \{ i\} }(X-v_j)/(v_i-v_j)\). When \(i\notin s\) this is the normalized nodal product, extending the cardinal-polynomial construction. Reference: [DLMF, 3.3(i)].

Lean Formalisation
def Lagrange.classicalBasis.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] (s : Finset ι) (v : ι → F)
  (i : ι) (_d : Lagrange.BasisInput s v i) : Polynomial F
Lean definition
/-- The classical normalized nodal product (DLMF §3.3(i)). -/
noncomputable def classicalBasis (s : Finset ι) (v : ι → F) (i : ι)
    (_d : BasisInput s v i) : F[X] := Lagrange.basis s v i
source
Theorem 2.4.13 Classical Lagrange product characterisation
✓ 🤖

The polynomial is the displayed product, has \(\ell _i(v_i)=1\), and vanishes at \(v_j\) for \(j\in s\), \(j\ne i\). In particular it is nonzero.

Lean Formalisation
theorem Lagrange.classicalBasis_eq_product.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] (s : Finset ι)
  (v : ι → F) (i : ι) (d : Lagrange.BasisInput s v i) :
  Lagrange.classicalBasis s v i d = ∏ j ∈ s.erase i, Polynomial.C (v i - v j)⁻¹ * (Polynomial.X - Polynomial.C (v j))
Lean proof
/-- Product formula, with every denominator certified nonzero by the input. -/
theorem classicalBasis_eq_product (s : Finset ι) (v : ι → F) (i : ι)
    (d : BasisInput s v i) :
    classicalBasis s v i d =
      ∏ j ∈ s.erase i, Polynomial.C ((v i - v j)⁻¹) * (X - C (v j)) := rfl
source
Theorem 2.4.14 Real and complex cardinal products
✓ 🤖

For a finite set of natural indices \(S\), real nodes \(v_i\), and any index \(j\) with \(v_j\ne v_i\) for every \(i\in S\setminus \{ j\} \), the normalized cardinal product has the same value at a real point whether computed over \(\mathbb R\) or over \(\mathbb C\). The same separation condition holds over \(\mathbb C\). The index \(j\) need not belong to \(S\).

Lean Formalisation
theorem Polynomial.Chebyshev.complex_basisInput {s : Finset ℕ} {v : ℕ → ℝ} {j : ℕ} (d : Lagrange.BasisInput s v j) :
  Lagrange.BasisInput s (fun i => ↑(v i)) j
Lean proof
/-- Real nodes give separated complex nodes whenever the real product is classical. -/
theorem complex_basisInput {s : Finset ℕ} {v : ℕ → ℝ} {j : ℕ}
    (d : Lagrange.BasisInput s v j) :
    Lagrange.BasisInput s (fun i ↦ (v i : ℂ)) j :=
  ⟨fun i hi h ↦ d.separated i hi (Complex.ofReal_injective h)⟩
source
Theorem 2.4.15 Lagrange interpolation
✓ 🤖

For a finite set \(s\) of indices and distinct field-valued nodes \(v_i\), there are Lagrange polynomials \(\ell _i\) with \(\ell _i(v_j)=\delta _{ij}\) for \(i,j\in s\). Each \(\ell _i\) is nonzero of degree \(|s|-1\), and every polynomial of degree less than \(|s|\) is its Lagrange interpolant.

Reference: [DLMF, 3.3(i)].

Lean Formalisation
theorem Lagrange.natDegree_classicalBasis.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] {s : Finset ι}
  {v : ι → F} (hv : Set.InjOn v ↑s) {i : ι} (hi : i ∈ s) : (Lagrange.classicalBasis s v i ⋯).natDegree = s.card - 1
Lean proof
/-- Degree at an interpolation node (DLMF §3.3(i)). -/
theorem natDegree_classicalBasis {s : Finset ι} {v : ι → F}
    (hv : Set.InjOn v s) {i : ι} (hi : i ∈ s) :
    (classicalBasis s v i (BasisInput.of_injOn hv hi)).natDegree = s.card - 1 :=
  natDegree_basis hv hi
source
Definition 2.4.16 Classical nodal weights
✓ 🤖
#

For an admissible index \(i\) of Definition 2.4.10, define \(\omega _i=\prod _{j\in s\setminus \{ i\} }(v_i-v_j)^{-1}\). This also permits \(i\notin s\) whenever all displayed denominators are nonzero. Reference: [DLMF, 3.3(i)].

Lean Formalisation
def Lagrange.classicalNodalWeight.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] (s : Finset ι)
  (v : ι → F) (i : ι) (_d : Lagrange.BasisInput s v i) : F
Lean definition
/-- Nodal product weight with its precise classical denominator domain. -/
noncomputable def classicalNodalWeight (s : Finset ι) (v : ι → F) (i : ι)
    (_d : BasisInput s v i) : F := nodalWeight s v i
source

The weight is the displayed product and is nonzero. Writing \(q(X)=\prod _{j\in s}(X-v_j)\), if \(i\in s\) then \(q'(v_i)\ne 0\) and \(\omega _i=1/q'(v_i)\). For \(i\in s\) and \(x\ne v_i\), \(\ell _i(x)=q(x)\omega _i/(x-v_i)\).

Lean Formalisation
theorem Lagrange.classicalNodalWeight_apply.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] (s : Finset ι)
  (v : ι → F) (i : ι) (d : Lagrange.BasisInput s v i) :
  Lagrange.classicalNodalWeight s v i d = ∏ j ∈ s.erase i, (v i - v j)⁻¹
Lean proof
/-- Classical product formula, including valid off-node extensions. -/
theorem classicalNodalWeight_apply (s : Finset ι) (v : ι → F) (i : ι)
    (d : BasisInput s v i) :
    classicalNodalWeight s v i d = ∏ j ∈ s.erase i, (v i - v j)⁻¹ := rfl
source
Definition 2.4.18 Finite interpolation configurations
✓ 🤖
#

A finite interpolation configuration consists of a finite index set \(s\) and field-valued nodes \((v_i)_{i\in s}\) with \(v_i\ne v_j\) whenever \(i\ne j\). The set \(s\) may be empty.

Lean Formalisation
inductive Lagrange.InterpolationInput.{u_1, u_2} {F : Type u_1} {ι : Type u_2} (s : Finset ι) (v : ι → F) : Prop
Lean definition
/-- Distinct-node data for classical interpolation, including the empty set. -/
structure InterpolationInput (s : Finset ι) (v : ι → F) : Prop where
  distinct : Set.InjOn v s
source
Theorem 2.4.19 Nonvanishing denominators at interpolation nodes
✓ 🤖

For a finite interpolation configuration \((s,v)\), every \(i\in s\) satisfies \(v_i-v_j\ne 0\) for \(j\in s\setminus \{ i\} \), so the normalized nodal product \(\ell _i\) is defined.

Lean Formalisation
theorem Lagrange.InterpolationInput.basis.{u_1, u_2} {F : Type u_1} {ι : Type u_2} [DecidableEq ι] {s : Finset ι} {v : ι → F}
  (d : Lagrange.InterpolationInput s v) (i : ↥s) : Lagrange.BasisInput s v ↑i
Lean proof
/-- Every interpolation node has a valid classical product. -/
theorem InterpolationInput.basis {s : Finset ι} {v : ι → F}
    (d : InterpolationInput s v) (i : s) : BasisInput s v i :=
  BasisInput.of_injOn d.distinct i.property
source
Definition 2.4.20 Classical interpolation polynomial
✓ 🤖
#

For a finite interpolation configuration \((s,v)\) and values \((r_i)_{i\in s}\), define \(I r=\sum _{i\in s}r_i\ell _i\). For the empty set this is the zero polynomial. Reference: [DLMF, 3.3(i)].

Lean Formalisation
def Lagrange.classicalInterpolate.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] (s : Finset ι)
  (v : ι → F) (_d : Lagrange.InterpolationInput s v) (r : ι → F) : Polynomial F
Lean definition
/-- Classical interpolation polynomial (DLMF §3.3(i)). -/
noncomputable def classicalInterpolate (s : Finset ι) (v : ι → F)
    (_d : InterpolationInput s v) (r : ι → F) : F[X] := interpolate s v r
source
Theorem 2.4.21 Classical interpolation characterisation
✓ 🤖

The interpolant is the displayed cardinal-polynomial sum, attains the data at every node, and has degree less than \(|s|\), with the degree of zero understood as \(-\infty \).

Lean Formalisation
theorem Lagrange.classicalInterpolate_apply.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] (s : Finset ι)
  (v : ι → F) (d : Lagrange.InterpolationInput s v) (r : ι → F) :
  Lagrange.classicalInterpolate s v d r = ∑ i, Polynomial.C (r ↑i) * Lagrange.classicalBasis s v ↑i ⋯
Lean proof
/-- Expansion in the classical cardinal polynomials. -/
theorem classicalInterpolate_apply (s : Finset ι) (v : ι → F)
    (d : InterpolationInput s v) (r : ι → F) :
    classicalInterpolate s v d r = ∑ i : s, C (r i) * classicalBasis s v i (d.basis i) := by
  exact (Finset.sum_coe_sort s (fun i ↦ C (r i) * Lagrange.basis s v i)).symm
source
Definition 2.4.22 Domain of barycentric evaluation
✓ 🤖
#

A barycentric evaluation configuration consists of a nonempty finite set of distinct nodes and an evaluation point \(z\) different from every node.

Lean Formalisation
inductive Lagrange.BarycentricInput.{u_1, u_2} {F : Type u_1} {ι : Type u_2} (s : Finset ι) (v : ι → F) : Type u_1
Lean definition
/-- Nonempty distinct nodes and an evaluation point off all nodes. -/
structure BarycentricInput (s : Finset ι) (v : ι → F) where
  nodes : InterpolationInput s v
  nonempty : s.Nonempty
  point : {x : F // ∀ i ∈ s, x ≠ v i}
source
Theorem 2.4.23 Nonvanishing barycentric denominators
✓ 🤖

For each node, \(\omega _i\ne 0\) and \(z-v_i\ne 0\).

Lean Formalisation
theorem Lagrange.BarycentricInput.valid.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι] {s : Finset ι}
  {v : ι → F} (d : Lagrange.BarycentricInput s v) (i : ↥s) :
  Lagrange.classicalNodalWeight s v ↑i ⋯ ≠ 0 ∧ ↑d.point - v ↑i ≠ 0
Lean proof
/-- Both the nodal and point-difference denominators are nonzero. -/
theorem BarycentricInput.valid {s : Finset ι} {v : ι → F}
    (d : BarycentricInput s v) (i : s) :
    classicalNodalWeight s v i (d.nodes.basis i) ≠ 0 ∧ d.point.val - v i ≠ 0 :=
  ⟨classicalNodalWeight_ne_zero _ _ _ _, sub_ne_zero.mpr (d.point.property i i.property)⟩
source

2.4.2 From values to coefficients

Discrete orthogonality gives a cosine transform of the sampled values. The half weights at the endpoints also affect the first and last coefficient.

Definition 2.4.24 Half-endpoint discrete sum and DCT-I coefficients
✓ 🤖

For \(N\ge 1\), put \(x_j=\cos (j\pi /N)\) and \(S_N(g)=\tfrac 12g(0)+\sum _{j=1}^{N-1}g(j)+\tfrac 12g(N)\). For real-valued data and \(0\le k\le N\), define

\[ c_k=\frac{2-\mathbf1_{k=0\text{ or }k=N}}{N} S_N\bigl(j\mapsto f(x_j)T_k(x_j)\bigr),\qquad P_Nf=\sum _{k=0}^N c_kT_k. \]

For \(N=0\), define \(P_0f\) to be the constant polynomial \(f(1)\).

Reference: [ATAP, Chapters 4 and 6].

Lean Formalisation
def Polynomial.Chebyshev.extremaSum (N : { n // 0 < n }) (f : ℕ → ℝ) : ℝ
Lean definition
/-- The endpoint-half-weighted sum on the extrema indices `0,...,N`.
This is the usual double-primed sum at positive order. -/
noncomputable def extremaSum (N : {n : ℕ // 0 < n}) (f : ℕ → ℝ) : ℝ :=
  (∑ j ∈ Finset.range N.val, f j) + (f N.val - f 0) / 2
source

For \(N\ge 1\) and \(0\le j,k\le N\), the discrete inner product \(S_N(\ell \mapsto T_j(x_\ell )T_k(x_\ell ))\) vanishes if \(j\ne k\). Its diagonal is \(N\) for \(k=0,N\) and \(N/2\) otherwise. Consequently \(c_k(T_j)=\delta _{jk}\).

Reference: [ATAP, Chapter 4].

Lean Formalisation
theorem Polynomial.Chebyshev.extremaSum_mul_eval_T_eq_zero {N j k : ℕ} (hj : j ≤ N) (hk : k ≤ N) (hjk : j ≠ k) :
  (Polynomial.Chebyshev.extremaSum ⟨N, ⋯⟩ fun m =>
      Polynomial.eval (Polynomial.Chebyshev.node N m) (Polynomial.Chebyshev.T ℝ ↑j) *
        Polynomial.eval (Polynomial.Chebyshev.node N m) (Polynomial.Chebyshev.T ℝ ↑k)) =
    0
Lean proof
/-- Distinct Chebyshev modes through degree `N` are discretely orthogonal. -/
theorem extremaSum_mul_eval_T_eq_zero {N j k : ℕ}
    (hj : j ≤ N) (hk : k ≤ N) (hjk : j ≠ k) :
    extremaSum ⟨N, by omega⟩ (fun m ↦ (T ℝ j).eval (node N m) * (T ℝ k).eval (node N m)) = 0 := by
  wlog hkj : k ≤ j generalizing j k
  · have h := this hk hj hjk.symm (by omega)
    simpa only [mul_comm] using h
  have h := extremaSum_product (N := N) (by omega) hkj
  rw [extremaSum_eval_T (by omega : j + k < 2 * N),
    extremaSum_eval_T (by omega : j - k < 2 * N),
    ite_eq_right (by omega : j + k ≠ 0), ite_eq_right (by omega : j - k ≠ 0)] at h
  linarith
source

For \(N\ge 1\), \(P_Nf\) equals the Lagrange interpolant at the extrema and \(P_Nf(x_j)=f(x_j)\) for \(0\le j\le N\). It reproduces every real polynomial of degree at most \(N\). Its integral-defined Chebyshev coefficient of index \(k\) is \(c_k\) for \(k\le N\) and zero otherwise.

Reference: [ATAP, Chapters 4 and 6].

Lean Formalisation
theorem Polynomial.Chebyshev.dctInterpolant_eval {N : ℕ} (hN : N ≠ 0) {p : Polynomial ℝ} (hp : p.degree ≤ ↑N) :
  (Polynomial.Chebyshev.dctInterpolant N fun x => Polynomial.eval x p) = p
Lean proof
/-- Resolved polynomial data are reconstructed exactly by the DCT-I. -/
theorem dctInterpolant_eval {N : ℕ} (hN : N ≠ 0) {p : ℝ[X]} (hp : p.degree ≤ N) :
    dctInterpolant N (fun x ↦ p.eval x) = p := by
  have hm : p ∈ Submodule.span ℝ (chebyshevTsequence ℝ '' Set.Iic N) := by
    rw [(chebyshevTsequence ℝ).span_degreeLE
      (fun i _ ↦ (chebyshevTsequence ℝ).isUnit_leadingCoeff i), mem_degreeLE]
    exact hp
  clear hp
  induction hm using Submodule.span_induction with
  | mem p hp =>
    obtain ⟨j, hj, rfl⟩ := hp
    change j ≤ N at hj
    change dctInterpolant N (fun x ↦ (T ℝ j).eval x) = T ℝ j
    simp only [dctInterpolant, dite_eq_right hN]
    have he (k : Fin (N + 1)) :=
      extremaCoefficient_eval_T hN hj (Nat.le_of_lt_succ k.isLt)
    simp_rw [he]
    rw [Fin.sum_univ_eq_sum_range (fun k ↦ Polynomial.C (if j = k then (1 : ℝ) else 0) * T ℝ k)]
    simp [show j < N + 1 by omega]
  | zero => simp [dctInterpolant, extremaCoefficient, extremaSum]
  | add p q _ _ hp hq =>
    simp only [eval_add, dctInterpolant, dite_eq_right hN, extremaCoefficient_add, map_add,
      add_mul, Finset.sum_add_distrib] at hp hq ⊢
    rw [hp, hq]
  | smul a p _ hp =>
    simp only [eval_smul, smul_eq_mul, extremaCoefficient_mul, dctInterpolant, dite_eq_right hN,
      map_mul, mul_assoc, ← Finset.mul_sum] at hp ⊢
    rw [hp]
    exact (smul_eq_C_mul a).symm
source

Example (Julia).

This direct implementation evaluates the DCT formula in \(O(N^2)\) operations. Sampling \(T_3\) at six extrema gives its unit coefficient vector in exact arithmetic. The computation uses floating-point values. An FFT-based implementation can be faster; none is implemented here.


function chebcoeffs(f, N)            # c_k of Definition (DCT-I)
    @assert N >= 1
    x = [cos(j*pi/N) for j in 0:N]
    w = [j == 0 || j == N ? 1/2 : 1.0 for j in 0:N]
    [(k == 0 || k == N ? 1 : 2)/N *
        sum(w[j+1]*f(x[j+1])*cos(k*j*pi/N) for j in 0:N) for k in 0:N]
end
chebcoeffs(x -> 4x^3 - 3x, 5)        # [0, 0, 0, 1, 0, 0] up to rounding
Discrete-transform identities
Theorem 2.4.27 Discrete-transform characterisation
✓ 🤖

For positive order the coefficients are the stated half-endpoint cosine sum. For \(N=0\), \(P_0f\) is the constant polynomial \(f(1)\).

Lean Formalisation
theorem Polynomial.Chebyshev.extremaCoefficient_positive (N : { n // 0 < n }) (f : ℝ → ℝ) (k : Fin (↑N + 1)) :
  Polynomial.Chebyshev.extremaCoefficient N f k =
    (if ↑k = 0 ∨ ↑k = ↑N then 1 else 2) / ↑↑N *
      Polynomial.Chebyshev.extremaSum N fun j =>
        f (Polynomial.Chebyshev.classicalNode N j) *
          Polynomial.eval (Polynomial.Chebyshev.classicalNode N j) (Polynomial.Chebyshev.T ℝ ↑↑k)
Lean proof
/-- Classical positive-order DCT-I formula, in the full-constant convention. -/
theorem extremaCoefficient_positive (N : {n : ℕ // 0 < n}) (f : ℝ → ℝ)
    (k : Fin (N.val + 1)) :
    extremaCoefficient N f k = (if k.val = 0 ∨ k.val = N.val then 1 else 2) / N.val *
      extremaSum N (fun j ↦ f (classicalNode N j) *
        (T ℝ k.val).eval (classicalNode N j)) := rfl
source

2.4.3 Aliasing and interpolation error

Frequencies above the grid order can have identical samples. The folded index identifies which coefficients become indistinguishable.

Definition 2.4.28 Folded frequency
✓ 🤖
#

For \(N\ge 1\), fold a frequency \(k\) by setting \(r=k\bmod 2N\) and \(A_N(k)=\min (r,2N-r)\). For \(N=0\), set \(A_0(k)=0\).

Lean Formalisation
def Polynomial.Chebyshev.aliasIndex (N k : ℕ) : ℕ
Lean definition
/-- The degree obtained by folding a frequency into `[0,N]` (ATAP, Chapter 4). -/
def aliasIndex (N k : ℕ) : ℕ :=
  if N = 0 then 0 else min (k % (2 * N)) (2 * N - k % (2 * N))
source

For \(N\ge 1\), set \(r=k\bmod 2N\) and \(m=\min (r,2N-r)\). Then \(0\le m\le N\), \(m=k\) if \(k\le N\), and \(T_k(\cos (j\pi /N))=T_m(\cos (j\pi /N))\) for every nonnegative integer \(j\). At order zero, \(A_0(k)=0\) for every \(k\).

Reference: [ATAP, Chapter 4].

Lean Formalisation
theorem Polynomial.Chebyshev.aliasIndex_zero (k : ℕ) : Polynomial.Chebyshev.aliasIndex 0 k = 0
Lean proof
/-- The singleton grid folds all modes to its constant mode. -/
theorem aliasIndex_zero (k : ℕ) : aliasIndex 0 k = 0 := by simp [aliasIndex]
source

Let \(N\ge 1\), \(0\le k\le N\), and let \(A_N(m)\) be the folded alias index. For a finite expansion \(f=\sum _{m\in s}a_mT_m\),

\[ c_k(f)=\sum _{\substack {m\in s\\ A_N(m)=k}}a_m. \]

More generally, if \(\sum _{m\ge 0}a_mT_m(x_j)\) is absolutely summable with sum \(f(x_j)\) at every extremum, then \(\sum _{m\ge 0}\mathbf1_{A_N(m)=k}a_m\) is summable with sum \(c_k(f)\). Summability is unconditional: sums are limits over finite subsets of indices.

Reference: [ATAP, Theorem 4.2].

Lean Formalisation
theorem Polynomial.Chebyshev.extremaCoefficient_eval_T_alias {N k : ℕ} (hN : N ≠ 0) (hk : k ≤ N) (m : ℕ) :
  Polynomial.Chebyshev.extremaCoefficient ⟨N, ⋯⟩ (fun x => Polynomial.eval x (Polynomial.Chebyshev.T ℝ ↑m)) ⟨k, ⋯⟩ =
    if Polynomial.Chebyshev.aliasIndex N m = k then 1 else 0
Lean proof
/-- An arbitrary frequency contributes exactly to its folded DCT coefficient. -/
theorem extremaCoefficient_eval_T_alias {N k : ℕ} (hN : N ≠ 0) (hk : k ≤ N) (m : ℕ) :
    extremaCoefficient ⟨N, Nat.pos_of_ne_zero hN⟩ (fun x ↦ (T ℝ m).eval x)
      ⟨k, Nat.lt_succ_of_le hk⟩ =
      if aliasIndex N m = k then 1 else 0 := by
  rw [extremaCoefficient_congr (g := fun x ↦ (T ℝ (aliasIndex N m)).eval x)
    (fun j ↦ by simpa only [extremaGridNode_positive ⟨N,Nat.pos_of_ne_zero hN⟩] using
      eval_T_node_aliasIndex ⟨N,Nat.pos_of_ne_zero hN⟩ m j)]
  exact extremaCoefficient_eval_T hN (aliasIndex_le hN m) hk
source

Suppose \(\sum _{k\ge 0}|a_k|{\lt}\infty \) and \(f(x)=\sum _{k\ge 0}a_kT_k(x)\) on \([-1,1]\). For \(N\ge 1\) and \(x\in [-1,1]\),

\[ |f(x)-I_Nf(x)|\le 2\sum _{k{\gt}N}|a_k|. \]

In particular \(I_NT_k=T_m\) for the aliased index \(m\), so \(|I_NT_k(x)|\le 1\).

Reference: [ATAP, Chapter 4].

The nodal expansion is \(I_N f(z)=\sum _{j=0}^{N} f(x_{N,j})\ell _{N,j}(z)\) using the finite grid of Definition 2.4.2. Interpolation commutes with any Chebyshev series whose ordinary partial sums converge at each of these finitely many points; absolute convergence is not required. Both identities also hold for \(N=0\), when the only interpolation node is \(x_{0,0}=1\).

Lean Formalisation
theorem Polynomial.Chebyshev.extremaInterpolant_T {N : ℕ} (hN : N ≠ 0) (k : ℕ) :
  (Polynomial.Chebyshev.extremaInterpolant N fun t => ↑(Polynomial.eval t (Polynomial.Chebyshev.T ℝ ↑k))) =
    Polynomial.Chebyshev.T ℂ ↑(Polynomial.Chebyshev.aliasIndex N k)
Lean proof
/-- Interpolation folds a Chebyshev frequency into `[0,N]` (ATAP, Chapter 4). -/
theorem extremaInterpolant_T {N : ℕ} (hN : N ≠ 0) (k : ℕ) :
    extremaInterpolant N (fun t : ℝ ↦ (((T ℝ k).eval t : ℝ) : ℂ)) = T ℂ (aliasIndex N k) := by
  symm
  rw [extremaInterpolant_positive ⟨N,Nat.pos_of_ne_zero hN⟩]
  apply Lagrange.eq_interpolate_of_eval_eq _
    (Complex.ofReal_injective.comp_injOn (strictAntiOn_classicalNode ⟨N,Nat.pos_of_ne_zero hN⟩).injOn)
  · simp only [degree_T, Int.natAbs_natCast, Finset.card_range]
    exact_mod_cast (Nat.lt_succ_of_le (aliasIndex_le hN k))
  · intro j hj
    dsimp only [Function.comp_def]
    rw [← complex_ofReal_eval_T]
    exact congrArg Complex.ofReal
      (eval_T_node_aliasIndex ⟨N,Nat.pos_of_ne_zero hN⟩ k j).symm
source

2.4.4 Barycentric evaluation

The barycentric formula evaluates the interpolant directly from its samples. Its weights are \((-1)^j\), halved at the endpoints. At a node, use the prescribed sample value.

Definition 2.4.32 Extrema nodal polynomial and weights
✓ 🤖

For \(N\ge 1\) and \(0\le j\le N\), write \(x_j=\cos (j\pi /N)\) for the extrema nodes. Set \(F_N=(X^2-1)T_N'\), and let \(e_j=2\) for \(j=0\) or \(j=N\), and \(e_j=1\) otherwise. The normalised barycentric weights are \(w_j=(-1)^j/e_j\).

Reference: [ATAP, Theorem 5.2].

Lean Formalisation
def Polynomial.Chebyshev.extremaNodal (N : { n // 0 < n }) : Polynomial ℝ
Lean definition
/-- An unnormalised nodal polynomial for the extrema (ATAP, Chapter 5). -/
noncomputable def extremaNodal (N : {n : ℕ // 0 < n}) : ℝ[X] :=
  (X ^ 2 - 1) * derivative (T ℝ N.val)
source

For \(N\ge 1\), arbitrary \(f:\mathbb R\to \mathbb C\), and \(z\in \mathbb C\) distinct from all nodes,

\[ I_Nf(z)=\frac{\sum _{j=0}^N w_j f(x_j)/(z-x_j)}{\sum _{j=0}^N w_j/(z-x_j)}. \]

The denominator is nonzero. At a node the interpolant takes its prescribed value. The order-zero interpolant is the constant \(f(1)\). The product weights equal \(\operatorname {lc}(F_N)w_j/N^2\), with a nonzero common factor. For real \(x\ne x_j\), the cardinal polynomial satisfies

\[ \ell _j(x)=\frac{F_N(x)(-1)^j}{N^2 e_j(x-x_j)}. \]

Reference: [ATAP, Theorem 5.2].

Lean Formalisation
theorem Polynomial.Chebyshev.extremaEndpointFactor_pos (N : { n // 0 < n }) (j : Fin (↑N + 1)) :
  0 < Polynomial.Chebyshev.extremaEndpointFactor N j
Lean proof
/-- The endpoint factor is positive (ATAP, Chapter 5). -/
theorem extremaEndpointFactor_pos (N : {n : ℕ // 0 < n}) (j : Fin (N.val + 1)) : 0 < extremaEndpointFactor N j := by
  unfold extremaEndpointFactor
  split_ifs <;> norm_num
source

2.4.5 Sensitivity and near-best interpolation

The sum of the absolute cardinal values measures sensitivity to perturbations in the samples. Its maximum over the interval also controls the error relative to a polynomial competitor.

Definition 2.4.34 Extrema Lebesgue function
✓ 🤖

Define \(\lambda _N(x)=\sum _{j=0}^N|\ell _{N,j}(x)|\) using the classical finite-grid cardinal polynomials, for every real \(x\) and \(N\ge 0\). Reference: [ATAP, Chapter 15].

Lean Formalisation
def Polynomial.Chebyshev.extremaLebesgueFunction (N : ℕ) (x : ℝ) : ℝ
Lean definition
/-- The sum of absolute cardinal polynomials (ATAP, Chapter 15). -/
noncomputable def extremaLebesgueFunction (N : ℕ) (x : ℝ) : ℝ :=
  ∑ j : Fin (N + 1), ‖(extremaCardinal N j).eval (x : ℂ)‖
source

Here \(\sup \) is the least upper bound of a nonempty bounded set; the boundedness assertion is recorded in Theorem 2.4.40.

Definition 2.4.35 Classical extrema Lebesgue constant
✓ 🤖

For \(N\ge 0\), define \(\Lambda _N\) as the classical real supremum of \(\{ \lambda _N(x):x\in [-1,1]\} \). Reference: [ATAP, Chapter 15].

Lean Formalisation
def Polynomial.Chebyshev.extremaLebesgueSupremumInput (N : ℕ) : Real.SupremumInput
Lean definition
/-- The certified classical supremum domain of the Lebesgue function. -/
noncomputable def extremaLebesgueSupremumInput (N : ℕ) : Real.SupremumInput where
  carrier := extremaLebesgueFunction N '' Icc (-1) 1
  nonempty := ⟨extremaLebesgueFunction N 0, 0, by norm_num, rfl⟩
  bounded := bddAbove_extremaLebesgueFunction N
source

The Lebesgue function is bounded above on \([-1,1]\), so the real supremum is well-founded and bounds every pointwise value. For \(N\ge 1\),

\[ \lambda _N(x)\le 2\pi +2H_N\le 2\pi +2+2\log N,\qquad \Lambda _N\le 2\pi +2+2\log N. \]

For \(N=0\), \(\lambda _0(x)=\Lambda _0=1\).

Reference: [ATAP, Chapter 15]; its Theorem 15.2 gives the sharper constant.

Lean Formalisation
theorem Polynomial.Chebyshev.extremaLebesgueFunction_le_log {N : ℕ} (hN : N ≠ 0) {x : ℝ} (hx : x ∈ Set.Icc (-1) 1) :
  Polynomial.Chebyshev.extremaLebesgueFunction N x ≤ 2 * Real.pi + 2 + 2 * Real.log ↑N
Lean proof
/-- Explicit logarithmic growth on the entire closed interval (ATAP, Chapter 15,
nonsharp constants). -/
theorem extremaLebesgueFunction_le_log {N : ℕ} (hN : N ≠ 0) {x : ℝ}
    (hx : x ∈ Icc (-1) 1) :
    extremaLebesgueFunction N x ≤ 2 * π + 2 + 2 * log N := by
  obtain ⟨n, rfl⟩ := Nat.exists_eq_succ_of_ne_zero hN
  linarith [extremaLebesgueFunction_le_harmonic (n + 1) hx, harmonic_le_one_add_log (n + 1)]
source

For arbitrary \(f:\mathbb R\to \mathbb C\) and any complex polynomial \(p\) of degree at most \(N\), suppose \(|f(x)-p(x)|\le \varepsilon \) throughout \([-1,1]\). Then, on the same interval,

\[ |f(x)-I_Nf(x)|\le (1+\lambda _N(x))\varepsilon \le (1+\Lambda _N)\varepsilon . \]

For \(N\ge 1\), this is at most \((2\pi +3+2\log N)\varepsilon \). No continuity assumption is needed for this uniform-competitor formulation.

Reference: [ATAP, Theorem 15.1].

Lean Formalisation
theorem Polynomial.Chebyshev.norm_eval_extremaInterpolant_le (N : ℕ) (f : ℝ → ℂ) {M : ℝ}
  (hf : ∀ (j : Fin (N + 1)), ‖f (Polynomial.Chebyshev.extremaGridNode N j)‖ ≤ M) (x : ℝ) :
  ‖Polynomial.eval (↑x) (Polynomial.Chebyshev.extremaInterpolant N f)‖ ≤
    M * Polynomial.Chebyshev.extremaLebesgueFunction N x
Lean proof
/-- The Lebesgue function controls evaluation in terms of nodal data
(ATAP, Chapter 15). -/
theorem norm_eval_extremaInterpolant_le (N : ℕ) (f : ℝ → ℂ) {M : ℝ}
    (hf : ∀ j : Fin (N + 1), ‖f (extremaGridNode N j)‖ ≤ M) (x : ℝ) :
    ‖(extremaInterpolant N f).eval (x : ℂ)‖ ≤ M * extremaLebesgueFunction N x := by
  rw [eval_extremaInterpolant]
  apply (norm_sum_le _ _).trans
  simp_rw [norm_mul]
  rw [extremaLebesgueFunction, Finset.mul_sum]
  exact Finset.sum_le_sum fun j _ ↦
    mul_le_mul_of_nonneg_right (hf j) (norm_nonneg _)
source
Suprema and harmonic-sum estimates
Definition 2.4.38 Classical real supremum
✓ 🤖
#

For a nonempty set \(S\subseteq \mathbb {R}\) that is bounded above, define \(\sup S\) to be its least upper bound in \(\mathbb {R}\).

Lean Formalisation
inductive Real.SupremumInput : Type
Lean definition
/-- The classical domain of a finite real supremum. -/
structure SupremumInput where
  carrier : Set ℝ
  nonempty : carrier.Nonempty
  bounded : BddAbove carrier
source
Theorem 2.4.39 Classical real supremum characterisation
✓ 🤖
#

For a nonempty set \(S\subseteq \mathbb {R}\) that is bounded above, \(x\le \sup S\) for every \(x\in S\). If \(x\le b\) for every \(x\in S\), then \(\sup S\le b\).

Lean Formalisation
theorem Real.classicalSup_isLUB (d : Real.SupremumInput) : IsLUB d.carrier (Real.classicalSup d)
Lean proof
/-- The classical supremum is the least upper bound. -/
theorem classicalSup_isLUB (d : SupremumInput) : IsLUB d.carrier (classicalSup d) :=
  isLUB_csSup d.nonempty d.bounded
source

The function equals the displayed finite sum, is nonnegative, and \(\lambda _0(x)=1\). For \(x\in [-1,1]\), \(\lambda _N(x)\le 2\pi +2H_N\); in particular its range on that interval is bounded above. Reference: [ATAP, Chapter 15], with nonsharp constants.

Lean Formalisation
theorem Polynomial.Chebyshev.extremaLebesgueFunction_apply (N : ℕ) (x : ℝ) :
  Polynomial.Chebyshev.extremaLebesgueFunction N x =
    ∑ j, ‖Polynomial.eval (↑x) (Polynomial.Chebyshev.extremaCardinal N j)‖
Lean proof
/-- Classical finite-cardinal-sum formula (ATAP Chapter 15). -/
theorem extremaLebesgueFunction_apply (N : ℕ) (x : ℝ) :
    extremaLebesgueFunction N x = ∑ j : Fin (N + 1),
      ‖(extremaCardinal N j).eval (x : ℂ)‖ := rfl
source
Theorem 2.4.41 Lebesgue constant characterisation
✓ 🤖

The set \(\{ \lambda _N(x):x\in [-1,1]\} \) is nonempty and bounded above. The constant \(\Lambda _N\) is the least upper bound of \(\{ \lambda _N(x):x\in [-1,1]\} \).

Lean Formalisation
theorem Polynomial.Chebyshev.extremaLebesgueConstant_isLUB (N : ℕ) :
  IsLUB (Polynomial.Chebyshev.extremaLebesgueFunction N '' Set.Icc (-1) 1)
    (Polynomial.Chebyshev.extremaLebesgueConstant N)
Lean proof
/-- The Lebesgue constant is the genuine least upper bound. -/
theorem extremaLebesgueConstant_isLUB (N : ℕ) :
    IsLUB (extremaLebesgueFunction N '' Icc (-1) 1) (extremaLebesgueConstant N) :=
  Real.classicalSup_isLUB (extremaLebesgueSupremumInput N)
source

Define the product weights \(\omega _j=\prod _{i\ne j}(x_j-x_i)^{-1}\). For a nonempty finite set of distinct nodes, away from every node,

\[ I f(z)=\frac{\sum _j \omega _j f(x_j)/(z-x_j)}{\sum _j \omega _j/(z-x_j)}, \]

and the denominator is nonzero.

Reference: [ATAP, Theorem 5.1].

Lean Formalisation
theorem Lagrange.classicalBarycentric_denominator_ne_zero.{u_1, u_2} {F : Type u_1} [Field F] {ι : Type u_2} [DecidableEq ι]
  {s : Finset ι} {v : ι → F} (d : Lagrange.BarycentricInput s v) :
  ∑ i, Lagrange.classicalNodalWeight s v ↑i ⋯ * (↑d.point - v ↑i)⁻¹ ≠ 0
Lean proof
/-- The barycentric denominator cannot vanish on the classical input domain. -/
theorem classicalBarycentric_denominator_ne_zero {s : Finset ι} {v : ι → F}
    (d : BarycentricInput s v) :
    (∑ i : s, classicalNodalWeight s v i (d.nodes.basis i) *
      (d.point.val - v i)⁻¹) ≠ 0 := by
  change (∑ i : s, nodalWeight s v i * (d.point.val - v i)⁻¹) ≠ 0
  rw [Finset.sum_coe_sort s (fun i ↦ nodalWeight s v i * (d.point.val - v i)⁻¹)]
  exact sum_nodalWeight_mul_inv_sub_ne_zero d.nodes.distinct d.point.property d.nonempty
source

For \(N\ge 1\), \(F_N\) is a nonzero scalar multiple of the monic nodal polynomial:

\[ F_N=\operatorname {lc}(F_N)\prod _{j=0}^N(X-x_j),\qquad F_N'(x_j)=e_jN^2(-1)^j. \]

Also \(F_N(\cos \theta )=-N\sin \theta \sin (N\theta )\). The derivative of \(T_N\) vanishes at the interior nodes.

Reference: [ATAP, Chapters 3 and 5].

Lean Formalisation
theorem Polynomial.Chebyshev.eval_derivative_T_node {N j : ℕ} (hj0 : 0 < j) (hjN : j < N) :
  Polynomial.eval (Polynomial.Chebyshev.node N j) (Polynomial.derivative (Polynomial.Chebyshev.T ℝ ↑N)) = 0
Lean proof
/-- The derivative vanishes at the interior extrema (ATAP, Chapters 3 and 5). -/
theorem eval_derivative_T_node {N j : ℕ} (hj0 : 0 < j) (hjN : j < N) :
    (derivative (T ℝ N)).eval (node N j) = 0 := by
  have hN : (N : ℝ) ≠ 0 := by exact_mod_cast (show N ≠ 0 by omega)
  have hφ0 : 0 < (j : ℝ) * π / N := by positivity
  have hφπ : (j : ℝ) * π / N < π := by
    apply (div_lt_iff₀ (by positivity : (0 : ℝ) < N)).mpr
    exact mul_lt_mul_of_pos_right (by exact_mod_cast hjN) pi_pos |>.trans_eq (mul_comm _ _)
  have hs := (sin_pos_of_pos_of_lt_pi hφ0 hφπ).ne'
  apply (mul_eq_zero.mp (show (derivative (T ℝ N)).eval (node N j) *
      sin ((j : ℝ) * π / N) = 0 from ?_)).resolve_right hs
  rw [T_derivative_eq_U]
  simp only [eval_mul, eval_intCast, node, mul_assoc]
  rw [U_real_cos]
  push_cast
  rw [sub_add_cancel]
  have ha : (N : ℝ) * (j * π / N) = j * π := by field_simp
  rw [ha, sin_nat_mul_pi, mul_zero]
source

For \(N\ge 1\), \(0\le j\le N\) and \(\theta \in [0,\pi ]\),

\[ |\ell _j(\cos \theta )|\le \pi ,\qquad N\left|\theta -\frac{j\pi }{N}\right|\, |\ell _j(\cos \theta )| \le \pi |\sin (N\theta )|. \]

Reference: [ATAP, Chapter 15]; elementary trigonometric estimates.

Lean Formalisation
theorem Polynomial.Chebyshev.sin_mul_abs_sub_le_pi_mul_abs_cos_sub {θ φ : ℝ} (hθ : θ ∈ Set.Icc 0 Real.pi)
  (hφ : φ ∈ Set.Icc 0 Real.pi) : Real.sin θ * |θ - φ| ≤ Real.pi * |Real.cos θ - Real.cos φ|
Lean proof
/-- Cosine spacing controls the sine-weighted angular distance on `[0,π]`
(ATAP, Chapter 15, elementary trigonometric estimate). -/
theorem sin_mul_abs_sub_le_pi_mul_abs_cos_sub {θ φ : ℝ}
    (hθ : θ ∈ Icc 0 π) (hφ : φ ∈ Icc 0 π) :
    sin θ * |θ - φ| ≤ π * |cos θ - cos φ| := by
  have hmid : (sin θ + sin φ) / 2 ≤ sin ((θ + φ) / 2) := by
    convert strictConcaveOn_sin_Icc.concaveOn.2 hθ hφ
      (by norm_num : (0 : ℝ) ≤ 1 / 2) (by norm_num : (0 : ℝ) ≤ 1 / 2)
      (by norm_num : (1 / 2 : ℝ) + 1 / 2 = 1) using 1 <;>
      simp only [smul_eq_mul] <;> congr 1 <;> ring
  have hc : sin θ ≤ 2 * sin ((θ + φ) / 2) := by
    linarith [sin_nonneg_of_nonneg_of_le_pi hφ.1 hφ.2]
  have ha : |(θ - φ) / 2| ≤ π / 2 := by
    rw [abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 2)]
    exact (div_le_div_iff_of_pos_right (by norm_num)).mpr
      (abs_le.mpr ⟨by linarith [hθ.1, hφ.2], by linarith [hθ.2, hφ.1]⟩)
  have hs := mul_abs_le_abs_sin ha
  have hd : |θ - φ| ≤ π * |sin ((θ - φ) / 2)| := by
    rw [abs_div, abs_of_pos (by norm_num : (0 : ℝ) < 2)] at hs
    have := (mul_le_mul_of_nonneg_left hs pi_pos.le)
    field_simp at this
    nlinarith
  have hsa : 0 ≤ sin ((θ + φ) / 2) := sin_nonneg_of_nonneg_of_le_pi
    (by linarith [hθ.1, hφ.1]) (by linarith [hθ.2, hφ.2])
  calc
    _ ≤ (2 * sin ((θ + φ) / 2)) * (π * |sin ((θ - φ) / 2)|) :=
      mul_le_mul hc hd (abs_nonneg _) (by positivity)
    _ = _ := by
      rw [cos_sub_cos, abs_mul, abs_mul, abs_of_nonneg hsa]
      norm_num
      ring
source
Theorem 2.4.45 Harmonic reciprocal-distance bound
✓ 🤖
#

Let \(0\le t\le N\), \(M\ge 0\), and suppose \(0\le a_j\le M\) and \(|t-j|a_j\le 1\) for \(j=0,\ldots ,N\). Then

\[ \sum _{j=0}^N a_j\le 2M+2H_N,\qquad H_N=\sum _{j=1}^N\frac1j. \]

Reference: elementary harmonic-sum estimate used for [ATAP, Chapter 15].

Lean Formalisation
theorem Finset.sum_le_two_mul_add_harmonic {N : ℕ} {t M : ℝ} {a : ℕ → ℝ} (ht0 : 0 ≤ t) (htN : t ≤ ↑N) (hM : 0 ≤ M)
  (ha0 : ∀ j ≤ N, 0 ≤ a j) (haM : ∀ j ≤ N, a j ≤ M) (ha : ∀ j ≤ N, |t - ↑j| * a j ≤ 1) :
  ∑ j ∈ Finset.range (N + 1), a j ≤ 2 * M + 2 * ↑(harmonic N)
Lean proof
/-- A bounded nonnegative family with inverse-distance decay has a harmonic sum bound
(ATAP, Chapter 15, elementary estimate). -/
theorem sum_le_two_mul_add_harmonic {N : ℕ} {t M : ℝ} {a : ℕ → ℝ}
    (ht0 : 0 ≤ t) (htN : t ≤ N) (hM : 0 ≤ M)
    (ha0 : ∀ j ≤ N, 0 ≤ a j) (haM : ∀ j ≤ N, a j ≤ M)
    (ha : ∀ j ≤ N, |t - j| * a j ≤ 1) :
    ∑ j ∈ range (N + 1), a j ≤ 2 * M + 2 * (harmonic N : ℝ) := by
  let k := ⌊t⌋₊
  have hk : k ≤ N := Nat.floor_le_of_le htN
  have hkt : (k : ℝ) ≤ t := Nat.floor_le ht0
  have htk : t < k + 1 := Nat.lt_floor_add_one t
  have hsum {m : ℕ} (hm : m ≤ N) :
      ∑ j ∈ range m, ((j : ℝ) + 1)⁻¹ ≤ (harmonic N : ℝ) := by
    simp only [harmonic, Rat.cast_sum, Rat.cast_inv, Rat.cast_add, Rat.cast_natCast,
      Rat.cast_one, Nat.cast_add, Nat.cast_one]
    apply sum_le_sum_of_subset_of_nonneg (range_mono hm)
    intro i _ _
    positivity
  have hrec {j r : ℕ} (hr : r ≤ N) (hd : (j : ℝ) + 1 ≤ |t - r|) :
      a r ≤ ((j : ℝ) + 1)⁻¹ := by
    rw [← one_div]
    apply (le_div_iff₀ (by positivity : (0 : ℝ) < j + 1)).mpr
    simpa [mul_comm] using
      (mul_le_mul_of_nonneg_right hd (ha0 r hr)).trans (ha r hr)
  have hl : ∑ j ∈ range (k + 1), a j ≤ M + (harmonic N : ℝ) := by
    rw [sum_range_succ, ← sum_range_reflect a k]
    have hb : ∑ j ∈ range k, a (k - 1 - j) ≤
        ∑ j ∈ range k, ((j : ℝ) + 1)⁻¹ := by
      apply sum_le_sum
      intro j hj
      have hjk : j < k := mem_range.mp hj
      apply hrec (by omega)
      have hc : ((k - 1 - j : ℕ) : ℝ) = (k : ℝ) - 1 - j := by
        rw [Nat.cast_sub (by omega), Nat.cast_sub (by omega), Nat.cast_one]
      rw [abs_of_nonneg (by
        rw [hc]
        linarith only [hkt, htk, (Nat.cast_nonneg j : (0 : ℝ) ≤ j)]), hc]
      linarith
    linarith [hb.trans (hsum hk), haM k hk]
  have hr : ∑ j ∈ range (N - k), a (k + 1 + j) ≤ M + (harmonic N : ℝ) := by
    cases hm : N - k with
    | zero =>
      simp only [sum_range_zero]
      exact add_nonneg hM ((show (0 : ℝ) ≤ ∑ j ∈ range 0, ((j : ℝ) + 1)⁻¹ by simp).trans
        (hsum (Nat.zero_le N)))
    | succ m =>
      rw [sum_range_succ']
      have hb : ∑ j ∈ range m, a (k + 1 + (j + 1)) ≤
          ∑ j ∈ range m, ((j : ℝ) + 1)⁻¹ := by
        apply sum_le_sum
        intro j hj
        have hjm : j < m := mem_range.mp hj
        apply hrec (by omega)
        have hc : ((k + 1 + (j + 1) : ℕ) : ℝ) = (k : ℝ) + j + 2 := by
          push_cast
          ring
        rw [abs_of_nonpos (by
          rw [hc]
          linarith only [hkt, htk, (Nat.cast_nonneg j : (0 : ℝ) ≤ j)]), hc]
        linarith
      have hb' := hb.trans (hsum (show m ≤ N by omega))
      have hfirst := haM (k + 1) (by omega)
      simpa only [Nat.add_zero] using add_le_add hb' hfirst |>.trans_eq (add_comm _ _)
  have he : N + 1 = (k + 1) + (N - k) := by omega
  rw [he, sum_range_add]
  linarith
source
Theorem 2.4.46 Harmonic logarithmic bound
✓ 🤖
#

For \(N\ge 1\), \(H_N\le 1+\log N\).

Lean Formalisation
theorem harmonic_le_one_add_log_of_pos (n : { n // 0 < n }) : ↑(harmonic ↑n) ≤ 1 + Real.log ↑↑n
Lean proof
/-- The harmonic logarithmic bound at a positive natural index (ATAP, Chapter 15).
The index type excludes evaluation of the logarithm at zero. -/
theorem harmonic_le_one_add_log_of_pos (n : {n : ℕ // 0 < n}) :
    (harmonic n.val : ℝ) ≤ 1 + Real.log n.val :=
  harmonic_le_one_add_log n.val
source