Documentation

CslibFrontier.Foundations.Data.Polynomial.CoeffList

Polynomials as lists of their low coefficients #

Mathlib's Polynomial.ofCoeffList builds a polynomial from its coefficients, the constant coefficient first. This file evaluates such a polynomial by Horner's rule on the list (Polynomial.evalCoeffList), bounds its degree by the length of the list less one, lists the first n coefficients of a polynomial (Polynomial.coeffsBelow), which give the polynomial back when its degree is less than n. An interactive verifier receives polynomials in this form.

Splitting a list splits the polynomial: l₁ ++ l₂ gives ofCoeffList l₁ + X ^ l₁.length * ofCoeffList l₂ (Polynomial.ofCoeffList_append). Padding with zeros does not change it (Polynomial.ofCoeffList_takeD_of_length_le), and the zero-padded first m + k coefficients split into the first m and the next k (Polynomial.ofCoeffList_takeD_add). Divide-and-conquer multiplication of coefficient lists uses these splits.

Main definitions #

Main results #

def Polynomial.evalCoeffList {R : Type u_1} [Semiring R] (z : R) (l : List R) :
R

The value at z of the polynomial with coefficient list l, the constant coefficient first, by Horner's rule.

Instances For
    @[simp]
    theorem Polynomial.evalCoeffList_nil {R : Type u_1} [Semiring R] (z : R) :

    The empty coefficient list evaluates to 0.

    @[simp]
    theorem Polynomial.evalCoeffList_cons {R : Type u_1} [Semiring R] (z a : R) (l : List R) :
    evalCoeffList z (a :: l) = a + z * evalCoeffList z l

    Horner's step: a :: l evaluates to a + z * evalCoeffList z l.

    theorem Polynomial.eval_ofCoeffList {R : Type u_2} [CommSemiring R] (z : R) (l : List R) :

    The value of the polynomial with coefficient list l is given by Horner's rule.

    The polynomial with coefficient list l has degree at most l.length - 1.

    def Polynomial.coeffsBelow {R : Type u_1} [Semiring R] (P : Polynomial R) (n : ℕ) :

    The coefficients of X ^ 0, …, X ^ (n - 1) of a polynomial, in this order.

    Instances For
      @[simp]
      theorem Polynomial.length_coeffsBelow {R : Type u_1} [Semiring R] (P : Polynomial R) (n : ℕ) :

      coeffsBelow P n has length n.

      theorem Polynomial.ofCoeffList_coeffsBelow {R : Type u_1} [Semiring R] {P : Polynomial R} {n : ℕ} (hP : P.natDegree < n) :

      The first n coefficients of a polynomial of degree less than n give the polynomial back.

      theorem Polynomial.ofCoeffList_append {R : Type u_1} [Semiring R] (l₁ l₂ : List R) :
      ofCoeffList (l₁ ++ l₂) = ofCoeffList l₁ + X ^ l₁.length * ofCoeffList l₂

      Concatenating coefficient lists shifts the second polynomial past the first.

      Peeling the constant coefficient, with 0 for the empty list.

      @[simp]

      A list of zeros is the zero polynomial.

      Padding a coefficient list with zeros does not change the polynomial.

      theorem Polynomial.ofCoeffList_takeD_add {R : Type u_1} [Semiring R] (l : List R) (m k : ℕ) :

      The zero-padded first m + k coefficients split into the first m and the next k.