[Next] [Prev] [Right] [Left] [Up] [Index] [Root]
Factorization

Factorization

We describe the functions for multivariate polynomial factorization and associated computations. These are available only for a restricted range of coefficient rings.

Subsections

Factorization and Irreducibility

Factorization(p) : RngDPolElt -> [ < RngDPolElt, RngIntElt >], RngElt
Given a polynomial p in P=R[x_1, ..., x_n], this function returns: such that p=u.prod_i q_i^(k_i). The unit u will be chosen in an appropriate way; over a field it will be such that q=prod_i q_i^(k_i) is monic, and for R = Z it will equal the sign of the leading coefficient of p.

The coefficient ring R must be one of the following: the ring of integers Z, the field of rationals Q, or a rational function field over one of those.

SquareFreeFactorization(p) : RngDPolElt -> [ <RngDPolElt, RngIntElt> ]
Returns the squarefree factorization of the multivariate polynomial p as a sequence of tuples of length 2, each consisting of a (not necessarily irreducible) factor and an integer indicating the multiplicity. The factors do not contain the square of any polynomial of degree greater than 0. The coefficient ring R must be either the ring of integers Z, the field of rationals Q, or a rational function field over one of those.
IsIrreducible(f) : RngDPolElt -> BoolElt
Given a multivariate polynomial p over a ring R, this function returns true if p is irreducible over R and false otherwise. The coefficient ring R must be one of the following: the ring of integers Z, the field of rationals Q, or a rational function field over one of those.

Example RngDPol_Trinomials (H23E5)

We create a polynomial f in the polynomial ring in three indeterminates over the ring of integers by multiplying together various trinomials. The resulting product f has 461 terms and total degree 15.

> P<x, y, z> := PolynomialRing(IntegerRing(), 3);
> f := &*[x^i+y^j+z^k: i,j,k in [1..2]];
> print #Terms(f);
461
> print TotalDegree(f);
15
> time print Factorization(f);
[
    <x + y + z, 1>,
    <x + y + z^2, 1>,
    <x + y^2 + z, 1>,
    <x + y^2 + z^2, 1>,
    <x^2 + y + z, 1>,
    <x^2 + y + z^2, 1>,
    <x^2 + y^2 + z, 1>,
    <x^2 + y^2 + z^2, 1>
]
Time: 2.000

Example RngDPol_Vandermonde (H23E6)

We construct a Vandermonde matrix of rank 6, find its determinant, and factorize that determinant.

> // Create polynomial ring over R of rank n
> PRing := function(R, n)
>     P := PolynomialRing(R, n);
>     AssignNames( P, ["x" cat IntegerToString(i): i in [1..n]]);
>     return P;
> end function;
>
> // Create Vandermonde matrix of rank n
> Vandermonde := function(n)
>     P := PRing(IntegerRing(), n);
>     return MatrixRing(P, n) ! [P.i^(j - 1): i, j in [1 .. n]];
> end function;
>
> V := Vandermonde(6);
> print V;
[   1   x1 x1^2 x1^3 x1^4 x1^5]
[   1   x2 x2^2 x2^3 x2^4 x2^5]
[   1   x3 x3^2 x3^3 x3^4 x3^5]
[   1   x4 x4^2 x4^3 x4^4 x4^5]
[   1   x5 x5^2 x5^3 x5^4 x5^5]
[   1   x6 x6^2 x6^3 x6^4 x6^5]
> D := Determinant(V);
> print #Terms(D);
720
> print TotalDegree(D);
15
> time print Factorization(D);
[
    <x5 - x6, 1>,
    <x4 - x6, 1>,
    <x4 - x5, 1>,
    <x3 - x6, 1>,
    <x3 - x5, 1>,
    <x3 - x4, 1>,
    <x2 - x6, 1>,
    <x2 - x5, 1>,
    <x2 - x4, 1>,
    <x2 - x3, 1>,
    <x1 - x6, 1>,
    <x1 - x5, 1>,
    <x1 - x4, 1>,
    <x1 - x3, 1>,
    <x1 - x2, 1>
]
Time: 0.920

Example RngDPol_Heron (H23E7)

We construct a polynomial A2 in three indeterminants a, b, and c over the rational field such that A2 is the square of the area of the triangle with side lengths a, b, c. Using elementary trigonometry one can derive the expression (4 * a^2 * b^2 - (a^2 + b^2 - c^2)^2)/16 for A2. Factorizing A2 gives a nice formulation of the square of the area which is similar to that given by Heron's formula.

> P<a, b, c> := PolynomialRing(RationalField(), 3);
> A2 := 1/16 * (4*a^2*b^2 - (a^2 + b^2 - c^2)^2);
> print A2;
-1/16*a^4 + 1/8*a^2*b^2 + 1/8*a^2*c^2 - 1/16*b^4 + 1/8*b^2*c^2 - 1/16*c^4
> F, u := Factorization(A2);
> print F;
[
    <a - b - c, 1>,
    <a - b + c, 1>,
    <a + b - c, 1>,
    <a + b + c, 1>
]
> print u;
-1/16

Resultant and Discriminant

Discriminant(p, i) : RngDPolElt, RngIntElt -> RngDPolElt
Discriminant(p, v) : RngDPolElt, RngDPolElt -> RngDPolElt
The discriminant D of p in R[x_1, ..., x_n] is returned, where p is considered as a polynomial in v=x_i. The result will be an element of P again. The coefficient ring R must be a domain. There are two ways to indicate with respect to which variable the integral is to be taken: either one specifies i, the integer 1 <= i <= n that is the number of the variable (upon creation of P, corresponding to P.i) or the variable v itself (as an element of P).
Resultant(f, g, i) : RngDPolElt, RngDPolElt, RngIntElt -> RngDPolElt
Resultant(f, g, v) : RngDPolElt, RngDPolElt, RngDPolElt -> RngDPolElt
The resultant of multivariate polynomials f and g in P=R[x_1, ..., x_n] with respect to the variable v=x_i, which is by definition the determinant of the Sylvester matrix for f and g when considered as polynomials in the single variable x_i. The result will be an element of P again. The coefficient ring R must be a domain. There are two ways to indicate with respect to which variable the integral is to be taken: either one specifies i, the integer 1 <= i <= n that is the number of the variable (upon creation of P, corresponding to P.i) or the variable v itself (as an element of P).
[Next] [Prev] [Right] [Left] [Up] [Index] [Root]