Lagrange cardinal functions and the interpolating polynomial
DefinitionMetodosNumericos_interpolacaoDefsThe Lagrange cardinal function attached to a family of nodes, and the interpolating polynomial in Lagrange form .
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 MetodosNumericosRead-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 and a family of real numbers indexed by a type with elements.
The first takes an index and a real and returns the finite product
over all indices distinct from . Division is total: if for some , the corresponding factor is and the whole product is . For the product is empty and equals .
The second takes families and of reals and a real and returns
Neither definition assumes the nodes are distinct or ordered, and is an arbitrary family of values, not required to come from evaluating a function.