Documentation

Mathlib.Algebra.Polynomial.RuleOfSigns

Descartes' Rule of Signs #

We define the "sign changes" in the coefficients of a polynomial, and prove Descartes' Rule of Signs: a real polynomial has at most as many positive roots as there are sign changes. A sign change is when there is a positive coefficient followed by a negative coefficient, or vice versa, with any number of zero coefficients in between.

Main Definitions #

Main theorem #

Reference #

Wikipedia: Descartes' Rule of Signs

Counts the number of times that the coefficients in a polynomial change sign, with the convention that 0 can count as either sign.

Equations
Instances For
    @[simp]
    theorem Polynomial.signVariations_monomial {R : Type u_1} [Semiring R] [LinearOrder R] (d : ) (c : R) :

    Sign variations of a monomial are always zero.

    If the first two signs are the same, then sign_variations is unchanged by eraseLead

    If we drop the leading coefficient, the sign changes drop by 0 or 1 depending on whether the first two nonzero coeffients match.

    We can only lose, not gain, sign changes if we drop the leading coefficient.

    We can only lose at most one sign changes if we drop the leading coefficient.

    @[simp]

    The number of sign changes does not change if we negate.

    @[simp]
    theorem Polynomial.signVariations_C_mul {R : Type u_1} [Ring R] [LinearOrder R] [IsStrictOrderedRing R] {η : R} (P : Polynomial R) (hx : η 0) :

    The number of sign changes does not change if we multiply by any nonzero scalar.

    theorem Polynomial.signVariations_eraseLead_mul_X_sub_C {R : Type u_1} [Ring R] [LinearOrder R] [IsStrictOrderedRing R] {P : Polynomial R} {η : R} ( : 0 < η) (hP₀ : 0 < P.leadingCoeff) (hc : P.nextCoeff < 0) :

    If P's coefficients start with signs [+, -, ...], then multiplying by a binomial X - η commutes with eraseLead in the number of sign changes. This is because the product of P and X - η has the pattern [+, -, ...] as well, so then P.eraseLead starts with [-,...], and multiplying by X - η gives [-, ...] too.

    theorem Polynomial.succ_signVariations_X_sub_C_mul_monomial {R : Type u_1} [Ring R] [LinearOrder R] [IsStrictOrderedRing R] {η : R} {d : } {c : R} (hc : c 0) ( : 0 < η) :

    This lemma is really a specialization of succ_signVariations_le_sub_mul to monomials.

    If a polynomial starts with two positive coefficients, then the sign changes in the product (X - η) * P is the same as (X - η) * P.eraseLead. This lemma lets us do induction on the degree of P when P starts with matching coefficient signs. Of course this is also true when the first two coefficients of P are negative, but we just prove the case where they're positive since it's cleaner and sufficient for the later use.

    theorem Polynomial.succ_signVariations_le_X_sub_C_mul {R : Type u_1} [Ring R] [LinearOrder R] [IsStrictOrderedRing R] {P : Polynomial R} {η : R} ( : 0 < η) (hP : P 0) :

    Multiplying a polynomial by a linear term X - η adds at least one sign change. This is the basis for the induction in roots_countP_pos_le_signVariations.

    Descartes' Rule of Signs: the number of positive roots is at most the number of sign variations.