Hensel Lifting

advertisement
Hensel Lifting
Consider the polynomial x5 + 5x4 − 3x3 − 18x2 + 25x + 14. We want to factor it using hensel
lifting for the prime 2. We start setting up the polynomial and its factorization modulo 2:
gap> x:=X(Rationals,"x");;
gap> f:=x^5+5*x^4-3*x^3-18*x^2+25*x+14;;
gap> p:=2;;
gap> X(GF(2),"x");; # so that the ‘x’ over GF(2) is printed nicely
gap> fmod:=UnivariatePolynomial(GF(2),
> CoefficientsOfUnivariatePolynomial(f)*Z(2)^0,1);
x^5+x^4+x^3+x
gap> ps:=Factors(fmod);
[ x, x+Z(2)^0, x^3+x+Z(2)^0 ]
Now we form the p̃i : For this we form lists that list for all i all factor indices but i.
gap> List([1..3],i->Difference([1..3],[i]));
[ [ 2, 3 ], [ 1, 3 ], [ 1, 2 ] ]
gap> ptild:=List([1..3],i->Product(ps{Difference([1..3],[i])}));
[ x^4+x^3+x^2+Z(2)^0, x^4+x^2+x, x^2+x ]
To compute the ai we need to use the extended Eucliudean algorithm. However this only
takes two factors. Thus compute first for two factors and then combine in a second calculation. The ai get multiplied accordingly.
gap> gcd1:=Gcd(ptild[1],ptild[2]);
x^3+x+Z(2)^0
gap> a1:=GcdRepresentation(ptild[1],ptild[2]);
[ Z(2)^0, Z(2)^0 ]
gap> Gcd(gcd1,ptild[3]);
Z(2)^0
gap> a2:=GcdRepresentation(gcd1,ptild[3]);
[ Z(2)^0, x+Z(2)^0 ]
gap> a:=[a1[1]*a2[1],a1[2]*a2[1],a2[2]];
[ Z(2)^0, Z(2)^0, x+Z(2)^0 ]
gap> Sum([1..3],i->a[i]*ptild[i]); # it works
Z(2)^0
Now we can start the hensel lifting for q = p = 2. We compute (in characteristic 0)
Q
t = 1q (f − pi ) and reduce modulo p.
gap> q:=p;;
gap> plift:=List(ps,i->UnivariatePolynomial(Rationals,
> List(CoefficientsOfUnivariatePolynomial(i),Int),1));
[ x, x+1, x^3+x+1 ]
gap> t:=1/q*(f-Product(plift));
2*x^4-2*x^3-10*x^2+12*x+7
gap> tmod:=UnivariatePolynomial(GF(2),
> CoefficientsOfUnivariatePolynomial(t)*Z(2)^0,1);
Z(2)^0
The p̂ are defined by ai (x)t(x) = p̂i (x) + li (x)pi (x). We lift to characteristic 0 and modify
the pi according to the formula p0i := pi + q p̂i :
gap> phm:=List([1..3],i->(a[i]*tmod) mod ps[i]);
[ Z(2)^0, Z(2)^0, x+Z(2)^0 ]
gap> ph:=List(phm,i->UnivariatePolynomial(Rationals,
> List(CoefficientsOfUnivariatePolynomial(i),Int),1));
[ 1, 1, x+1 ]
gap> pnew:=List([1..3],i->plift[i]+q*ph[i]);
[ x+2, x+3, x^3+3*x+3 ]
gap> f-Product(pnew);
-12*x^3-36*x^2-8*x-4
We see that indeed we got a factorization modulo pq = 4. We set this as our new q and
perform the next lifting step:
gap> q:=q*p;
4
gap> plift:=pnew;;
gap> t:=1/q*(f-Product(plift));
-3*x^3-9*x^2-2*x-1
gap> tmod:=UnivariatePolynomial(GF(2),CoefficientsOfUnivariatePolynomial(t)*Z(2)^0,1);
x^3+x^2+Z(2)^0
gap> phm:=List([1..3],i->(a[i]*tmod) mod ps[i]);
[ Z(2)^0, Z(2)^0, Z(2)^0 ]
gap> ph:=List(phm,i->UnivariatePolynomial(Rationals,List(CoefficientsOfUnivariatePolyn
[ 1, 1, 1 ]
gap> pnew:=List([1..3],i->plift[i]+q*ph[i]);
[ x+6, x+7, x^3+3*x+7 ]
gap> f-Product(pnew);
-8*x^4-48*x^3-64*x^2-192*x-280
We iterate the next lifting step. Here some p̂ are zero, and (because of a bug I’ll have to fix)
the UnivariatePolynomial call runs into an error. We thus compute the characteristic 0
representations one-by-one by hand.
gap> q:=q*p;
8
gap> plift:=pnew;;
gap> t:=1/q*(f-Product(plift));
-x^4-6*x^3-8*x^2-24*x-35
gap> tmod:=UnivariatePolynomial(GF(2),CoefficientsOfUnivariatePolynomial(t)*Z(2)^0,1);
gap> phm:=List([1..3],i->(a[i]*tmod) mod ps[i]);
[ Z(2)^0, 0*Z(2), x ]
gap> ph:=List(phm,i->UnivariatePolynomial(Rationals,List(CoefficientsOfUnivariatePolyn
Error, no method found! For debugging hints type ?Recovery from NoMethodFound
[...]
gap> ph[1]:=UnivariatePolynomial(Rationals,List(CoefficientsOfUnivariatePolynomial(phm
1
gap> ph[2]:=0;;
gap> ph[3]:=UnivariatePolynomial(Rationals,List(CoefficientsOfUnivariatePolynomial(phm
x
gap> pnew:=List([1..3],i->plift[i]+q*ph[i]);
[ x+14, x+7, x^3+11*x+7 ]
gap> f-Product(pnew);
-16*x^4-112*x^3-256*x^2-1200*x-672
We iterate one further step:
gap> q:=q*p;
16
[...]
Now we have a factorization modulo q = 32. We symmetrize the coefficients (by hand is
easier than writing a new function)
gap> q:=q*p;
32
gap> plift:=pnew;
[ x+14, x+23, x^3+27*x+7 ]
gap> ps:=[plift[1],plift[2]-q,plift[3]-q*x];
[ x+14, x-9, x^3-5*x+7 ]
Factor 1 might divide, but does not. Factor 2 has no chance (9 6 |14). Factor 3 divides.
gap> f/ps[1];
(x^5+5*x^4-3*x^3-18*x^2+25*x+14)/(x+14)
gap> f/ps[3];
x^2+5*x+2
This found all factors that are combination of one modular factor. The product of the
remaining 2 factors (index 1 and 2) therefore must be irreducible
gap> cofact:=ps[1]*ps[2];
x^2+5*x-126
gap> -126 mod q;
2
gap> cofact:=x^2+5*x+2;;
We get the factorization
f (x) = (x3 − 5x + 7) · (x2 + 5 ∗ x + 2)
Download