Skip to content

Improve sign consistency in rational polynomial factorization #33283

@real-or-random

Description

@real-or-random

The placement of the minus sign when factoring multivariate polynomials over QQ lost consistency at some point between Sage 9.2 and 9.4.

Define a multivariate polynomial ring:

sage: R.<ax,bx,ay,by,Az,Bz,Ai,Bi> = PolynomialRing(QQ, 8, order='invlex')
sage: R
Multivariate Polynomial Ring in ax, bx, ay, by, Az, Bz, Ai, Bi over Rational Field

Then, in Sage 9.2:

sage: R((-2 * (bx - ax)) ^ 1).factor()
(2) * (-bx + ax)
sage: R((-2 * (bx - ax)) ^ 2).factor()
(4) * (-bx + ax)^2
sage: R((-2 * (bx - ax)) ^ 3).factor()
(8) * (-bx + ax)^3

while in Sage 9.4 or Sage 9.5:

sage: R((-2 * (bx - ax)) ^ 1).factor()
(-2) * (bx - ax)
sage: R((-2 * (bx - ax)) ^ 2).factor()
(4) * (-bx + ax)^2
sage: R((-2 * (bx - ax)) ^ 3).factor()
(8) * (-bx + ax)^3

This broke our code in

It would be good to output a canonical form. A natural choice seems to make the leading coefficient of each factor positive.

It may then also be good to document that the factors will be primitive.

The invlex monomial ordering is not the culprit: the inconsistency also occurs with lex (see one comment down at the GitHub link).

Component: factorization

Issue created by migration from https://trac.sagemath.org/ticket/33283

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions