factor

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 = expand x
     
          32764
     o3 = -----
          32763
     
     o3 : QQ
     
We may peek inside x to a high depth to see its true structure as Expression.
     i4 = peek(x,100)
     
     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 Factorization and characteristic sets library). 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) (1)
     
     o6 : Product
     
The constant term is provided as the last factor.
     i7 = F = frac(ZZ/101[t])
     
     o7 = F
     
     o7 : FractionField
     
     i8 = factor ((t^3-1)/(t^3+1))
     
            2
          (t  + t + 1) (t - 1) (1)
     o8 = ------------------------
            2
          (t  - t + 1) (t + 1) (1)
     
     o8 : Divide
     
The code for factoring in a fraction field is easy to read:
     i9 = code(factor,F)
     
     -- enginering.m2:329
     	  factor F := (f,options) -> factor numerator f / factor denominator f;

Go to main index.

Go to concepts index.