Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Lagrange cardinal functions and the interpolating polynomial

Definition
MetodosNumericos_interpolacaoDefs

by LG · Sep 20, 2026 · Mathlib 0df444a (Lean v4.33.1)

interpolationnumerical-analysis

The Lagrange cardinal function Li(t)=prodjneqi(t−xj)/(xi−xj)L_i(t) = \\prod_{j \\neq i}(t-x_j)/(x_i-x_j)Li​(t)=prodjneqi​(t−xj​)/(xi​−xj​) attached to a family of nodes, and the interpolating polynomial in Lagrange form Pn(t)=sumifiLi(t)P_n(t) = \\sum_i f_i L_i(t)Pn​(t)=sumi​fi​Li​(t).

Definition code
import Mathlib

namespace MetodosNumericos

/-- The `i`-th Lagrange cardinal function for the nodes `x₀, …, xₙ`:
`Lᵢ(t) = ∏_{j ≠ i} (t - xⱼ) / (xᵢ - xⱼ)`. -/
noncomputable def lagrangeBasis {n : ℕ} (xs : Fin (n + 1) → ℝ) (i : Fin (n + 1)) (t : ℝ) : ℝ :=
  ∏ j ∈ Finset.univ.erase i, (t - xs j) / (xs i - xs j)

/-- The interpolating polynomial in Lagrange form (Fórmula de Lagrange):
`Pₙ(t) = ∑ᵢ fᵢ Lᵢ(t)`. -/
noncomputable def lagrangeInterp {n : ℕ} (xs fs : Fin (n + 1) → ℝ) (t : ℝ) : ℝ :=
  ∑ i : Fin (n + 1), fs i * lagrangeBasis xs i t

end MetodosNumericos
Source
S. R. Freitas, Métodos Numéricos (UFMS, 2000), Cap. 7, §7.3 Fórmula de Lagrange, pp. 138–140.
Read-back

What the Lean code literally says, in plain math · self-authored-by-drafting-agent (non-blind)

Disclosure: this read-back is not blind. It was written by the same agent that drafted the Lean code, at the explicit instruction of the mission's human owner, and not by an independent auditor with fresh context.

Both definitions are parameterised by a natural number nnn and a family x0,dots,xnx_0, \\dots, x_nx0​,dots,xn​ of real numbers indexed by a type with n+1n+1n+1 elements.

The first takes an index iii and a real ttt and returns the finite product

prodjneqifract−xjxi−xj,\\prod_{j \\neq i} \\frac{t - x_j}{x_i - x_j},prodjneqi​fract−xj​xi​−xj​,

over all indices jjj distinct from iii. Division is total: if xi=xjx_i = x_jxi​=xj​ for some jneqij \\neq ijneqi, the corresponding factor is 000 and the whole product is 000. For n=0n = 0n=0 the product is empty and equals 111.

The second takes families xxx and fff of n+1n+1n+1 reals and a real ttt and returns

sumi=0nfiprodjneqifract−xjxi−xj.\\sum_{i=0}^{n} f_i \\prod_{j \\neq i}\\frac{t-x_j}{x_i-x_j}.sumi=0n​fi​prodjneqi​fract−xj​xi​−xj​.

Neither definition assumes the nodes are distinct or ordered, and fff is an arbitrary family of values, not required to come from evaluating a function.

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me