diff --git a/books/bookvol10.4.pamphlet b/books/bookvol10.4.pamphlet
index 603c8ec..5a0db45 100644
--- a/books/bookvol10.4.pamphlet
+++ b/books/bookvol10.4.pamphlet
@@ -139486,8 +139486,8 @@ constraint the remainders will have huge numerators and denominators.
reverse result
--Compute the gcd between not coprime polynomials
- notCoprime(g:SUPP,p2:SUPP,ldeg:List NNI,_
- lvar1:List OV,ltry:List List R) : SUPP ==
+ notCoprime(g:SUPP, p2:SUPP, ldeg:List NNI,_
+ lvar1:List OV, ltry:List List R) : SUPP ==
g1:=gcd(g,differentiate g)
l1 := (g exquo g1)::SUPP
lg:LGcd:=localgcd(l1,p2,lvar1,ltry)
@@ -139579,10 +139579,21 @@ constraint the remainders will have huge numerators and denominators.
ground? p2 => false
degree(p1,mainVariable(p1)::OV) < degree(p2,mainVariable(p2)::OV)
+ best_to_front(l : List P) : List P ==
+ ress := []
+ best := first(l)
+ for p in rest l repeat
+ if better(p, best) then
+ ress := cons(best, ress)
+ best := p
+ else
+ ress := cons(p, ress)
+ cons(best, ress)
+
-- Gcd between polynomial p1 and p2 with
-- mainVariable p1 < x=mainVariable p2
gcdTermList(p1:P,p2:P) : P ==
- termList:=sort(better,
+ termList := best_to_front(
cons(p1,coefficients univariate(p2,(mainVariable p2)::OV)))
q:P:=termList.first
for term in termList.rest until q = 1$P repeat q:= gcd(q,term)
@@ -139617,52 +139628,58 @@ by iteratively ``lifting'' the solution modulo successive powers of $p$.
See Volume 10.1 for more details.
\begin{chunk}{package PGCD PolynomialGcdPackage}
+
--If there is a pol s.t. pol/gcd and gcd are coprime I can lift
lift?(p1:SUPP,p2:SUPP,uterm:UTerm,ldeg:List NNI, _
lvar:List OV) : _
Union(s:SUPP,failed:"failed",notCoprime:"notCoprime") ==
- leadpol:Boolean:=false
- (listpol,lval):=(uterm.lpol,uterm.lint.first)
- d:=listpol.first
- listpol:=listpol.rest
- nolift:Boolean:=true
- for uf in listpol repeat
- --note uf and d not necessarily primitive
- degree gcd(uf,d) =0 => nolift:=false
- nolift => ["notCoprime"]
- f:SUPP:=([p1,p2]$List(SUPP)).(position(uf,listpol))
- lgcd:=gcd(leadingCoefficient p1, leadingCoefficient p2)
- (l:=lift(f,d,uf,lgcd,lvar,ldeg,lval)) case "failed" => ["failed"]
+ (listpol, lval) := (uterm.lpol, first(uterm.lint))
+ d := first(listpol)
+ listpol := rest(listpol)
+ uf := listpol(1)
+ f := p1
+ --note uf and d not necessarily primitive
+ if degree gcd(uf, d) ~= 0 then
+ uf := listpol(2)
+ f := p2
+ if degree gcd(uf, d) ~= 0 then return ["notCoprime"]
+ lgcd := gcd(leadingCoefficient p1, leadingCoefficient p2)
+ l := lift(f, d, uf, lgcd, lvar, ldeg, lval)
+ l case "failed" => ["failed"]
[l :: SUPP]
-- interface with the general "lifting" function
lift(f:SUPP,d:SUP,uf:SUP,lgcd:P,lvar:List OV,
ldeg:List NNI,lval:List R):Union(SUPP,"failed") ==
- leadpol:Boolean:=false
- lcf:P
- lcf:=leadingCoefficient f
- df:=degree f
- leadlist:List(P):=[]
-
- if lgcd^=1 then
- leadpol:=true
- f:=lgcd*f
- ldeg:=[n0+n1 for n0 in ldeg for n1 in degree(lgcd,lvar)]
- lcd:R:=leadingCoefficient d
- if degree(lgcd)=0 then d:=((retract lgcd) *d exquo lcd)::SUP
- else d:=(retract(eval(lgcd,lvar,lval)) * d exquo lcd)::SUP
- uf:=lcd*uf
- leadlist:=[lgcd,lcf]
+ leadpol : Boolean := false
+ lcf : P
+ lcf := leadingCoefficient f
+ df := degree f
+ leadlist : List(P) := []
+
+ if lgcd ^= 1 then
+ leadpol := true
+ f := lgcd*f
+ ldeg := [n0+n1 for n0 in ldeg for n1 in degree(lgcd, lvar)]
+ lcd : R := leadingCoefficient d
+ lgcd1 :=
+ degree(lgcd) = 0 => retract lgcd
+ retract(eval(lgcd, lvar, lval))
+ du := (lgcd1*d) exquo lcd
+ du case "failed" => "failed"
+ d := du::SUP
+ uf := lcd*uf
+ leadlist := [lgcd, lcf]
lgu := imposelc([d, uf], lvar, lval, leadlist)
lgu case "failed" => "failed"
lg := lgu::List(SUP)
- (pl:=lifting(f,lvar,lg,lval,leadlist,ldeg,pmod)) case "failed" =>
+ (pl := lifting(f,lvar,lg,lval,leadlist,ldeg,pmod)) case "failed" =>
"failed"
plist := pl :: List SUPP
- (p0:SUPP,p1:SUPP):=(plist.first,plist.2)
- if completeEval(p0,lvar,lval) ^= lg.first then
- (p0,p1):=(p1,p0)
- ^leadpol => p0
+ (p0 : SUPP, p1 : SUPP) := (plist.first, plist.2)
+ if completeEval(p0, lvar, lval) ^= lg.first then
+ (p0, p1) := (p1, p0)
+ not leadpol => p0
p0 exquo content(p0)
-- Gcd for two multivariate polynomials
@@ -139688,7 +139705,7 @@ See Volume 10.1 for more details.
-- Gcd for a list of multivariate polynomials
gcd(listp:List P) : P ==
- lf:=sort(better,listp)
+ lf := best_to_front(listp)
f:=lf.first
for g in lf.rest repeat
f:=gcd(f,g)
diff --git a/changelog b/changelog
index e6dcdc3..1f06820 100644
--- a/changelog
+++ b/changelog
@@ -1,3 +1,7 @@
+20140603 tpd src/axiom-website/patches.html 20140603.03.tpd.patch
+20140603 tpd books/bookvol10.4 fix "bad reduction" in multivariate poly gcd
+20140603 tpd src/input/pgcd.input add pgcd test case
+20140603 tpd src/input/Makefile add pgcd.input
20140603 tpd src/axiom-website/patches.html 20140603.02.tpd.patch
20140603 tpd books/bookvolbib add published references from/to Axiom
20140603 tpd src/axiom-website/patches.html 20140603.01.tpd.patch
diff --git a/src/axiom-website/patches.html b/src/axiom-website/patches.html
index be17339..c97d73f 100644
--- a/src/axiom-website/patches.html
+++ b/src/axiom-website/patches.html
@@ -4366,6 +4366,8 @@ books/bookvol10.4 apply Waldek's changes to imposelc in PGCD
buglist, add todo 335: add packages to )d op gcd
20140603.02.tpd.patch
books/bookvolbib add published references from/to Axiom
+20140603.03.tpd.patch
+books/bookvol10.4 fix "bad reduction" in multivariate poly gcd