Polynomial in the book's index convention and Horner's coefficients
DefinitionMetodosNumericos_polinomiosDefsFor a coefficient family and a degree , , evaluated either at a real or at a complex point, and the Horner coefficients at a point , defined by and .
import Mathlib
namespace MetodosNumericos
/-- The polynomial `P(z) = a₀zⁿ + a₁z^{n-1} + ⋯ + aₙ` written with the book's
indexing convention: `a i` is the coefficient of `z^{n-i}`. -/
noncomputable def polyVal (a : ℕ → ℝ) (n : ℕ) (z : ℝ) : ℝ :=
∑ i ∈ Finset.range (n + 1), a i * z ^ (n - i)
/-- The same polynomial evaluated at a complex point. -/
noncomputable def polyValC (a : ℕ → ℝ) (n : ℕ) (z : ℂ) : ℂ :=
∑ i ∈ Finset.range (n + 1), (a i : ℂ) * z ^ (n - i)
/-- The coefficients produced by Horner's algorithm at the point `z`:
`b₀ = a₀` and `bᵢ = aᵢ + z b_{i-1}`. -/
noncomputable def hornerSeq (a : ℕ → ℝ) (z : ℝ) : ℕ → ℝ
| 0 => a 0
| i + 1 => a (i + 1) + z * hornerSeq a z i
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.
Three definitions are introduced, all parameterised by a function and a natural number .
The first returns, for a real , the finite sum , where the exponent is truncated natural-number subtraction (for it is the ordinary difference, and the summation index never exceeds ).
The second returns, for a complex , the sum with each real coefficient coerced into .
The third defines, for a real , a sequence indexed by the natural numbers: its value at is , and its value at is . The sequence is defined for all indices, not only up to , and reads values for arbitrarily large if evaluated beyond .
Nothing in these definitions asserts that or that vanishes beyond index .