[top][index]
search for:

factor -- factor a ring element

factor x -- factors x.

The result is a Product each of whose factors is a Power whose base is one of the factors found and whose exponent is an integer.

i1 : y = (2^15-4)/(2^15-5)

     32764
o1 = -----
     32763

o1 : QQ
i2 : x = factor y

       2
      2 8191
o2 = --------
     3*67*163

o2 : Divide
i3 : value x

     32764
o3 = -----
     32763

o3 : QQ

We may peek inside x to a high depth to see its true structure as Expression.

i4 : peek2(x,100)

o4 = Divide{Product{Power{2,2},Power{8191,1}},Product{Power{3,1},Power{67,1},Power{163,1}}}

For small integers factorization is done by trial division. Eventually we will have code for large integers. For multivariate polynomials the factorization is done with code of Michael Messollen (see Singular-Libfac). For univariate polynomials the factorization is in turn done with code of Gert-Martin Greuel and Ruediger Stobbe (see Factory library).

i5 : R = ZZ/101[u]

o5 = R

o5 : PolynomialRing
i6 : factor (u^3-1)

       2
o6 = (u  + u + 1)(u - 1)

o6 : Product

The constant term is provided as the last factor, if it's not equal to 1.

i7 : F = frac(ZZ/101[t])

o7 = F

o7 : FractionField
i8 : factor ((t^3-1)/(t^3+1))

       2
     (t  + t + 1)(t - 1)
o8 = -------------------
       2
     (t  - t + 1)(t + 1)

o8 : Divide

The code for factoring in a fraction field is easy to read:

i9 : code(factor,F)

o9 = -- ../../../../../Macaulay2/m2/enginering.m2:128
               factor F := options -> f -> factor numerator f / factor denominator f;

Ways to use factor :

  • factor QQ
  • factor ZZ
  • Optional arguments :


    [top][index]
    search for: