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 : Expression of class 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 : peek'(100,x)
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
Singular-Factory).
i5 : R = ZZ/101[u]
o5 = R
o5 : PolynomialRing
|
i6 : factor (u^3-1)
2
o6 = (u - 1)(u + u + 1)
o6 : Expression of class 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 - 1)(t + t + 1)
o8 = -------------------
2
(t + 1)(t - t + 1)
o8 : Expression of class Divide
|
The code for factoring in a fraction field is easy to read:
i9 : code(factor,F)
o9 = -- code for method: factor(F)
-- ../../../../Macaulay2/m2/enginering.m2:196
factor F := options -> f -> factor numerator f / factor denominator f;
| symbol class value location of symbol
| ------ ----- ----- ------------------
| ZZ
| R :PolynomialRing----- [t] ../../../../Macaulay2/m2/enginering.m2:186:45-186:45
| 101
| o :OptionTable --OptionTable{Adjust => identity $../../../../Macaulay2/m2/enginering.m2:187:10-187:10
| DegreeRank => 1 $
| Degrees => {{1}} $
| $$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$
| F :FractionField --F ../../../../Macaulay2/m2/enginering.m2:191:19-191:19
|