nomials is the product of the GCD of their contents and the GCD of their primitive
parts.
4.3
ALGORITHM 5I.
Let Z denote the domain of integers, and let Zp denote the
field of integers modulo a prime p. Let Fi' and F '
2 be given nonzero polynomials in
Z[Xl, ... , xo].
Algorithm M computes their GCD, G', and their
cofactors, H~' =
FI'/G'
and
H'2 = F2'/G',
making essential use of Algorithm P (Section 4.5), which
computes the GCD and cofactors of given nonzero polynomials in
Zp[Xl, .." , Xv].
Each of these algorithms obtains the cofactors for the essential purpose of verifying
the GCD; however, they are frequently a very welcome byproduct of the computa-
tion.
Let c~ = cont(F~'), c2 = cont(F2'), and c = gcd(o, c2). Also, let F1 =
Fi'/O,
F2 = F2'/c2,
G = gcd (F~, F2), H~ =
F~/G,
and H2 =
F2/G.
Then
G' = cG, H~' =
(cl/c)H1,
and
H2' =
(c~/c)H2.
Let f~, f2, g, h~, and h2 be the leading coefficients of F~, F~, G, H1, and H2, re-
spectively. As in Section 2.4, define ~ = gcd(f~, f~) and G =
((O/g)G.
Also, define
fil = oF~, F~ = OF2, tt~ = gH~,
and/42 =
gH2,
so that fi~ = G/41 and F~ =
¢//~.
Note thatpp(G) = G, lc(G) = g, lc(/41) =
gh~
= fl, and lc(/4:) =
gh~ = f~.
Observe that fl, f2, and ¢ can easily be obtained at the beginning of the computation,
while g cannot be known until the end.
Let d = i) (G). Although d cannot be determined until the end of the computation,
it is evident that d _< min (1) (F1), ~ (F~)).
At any given time in the execution of Algorithm M, there is a set of odd primes
pi,
"
•
"
,
p~ that have been used and not discarded. Furthermore, for i = 1, • • • , n,
the algorithm has computed
/~(~)
=
fi~ mod p~,
(31)
1
P(~)
F~ mod p~,
2
and
three
polynomials G(~), ~(~)
~(~)
t/~ , and///:
satisfying
=
• gcd (/~'~ , ,. e )
(32)
and
1
~(~)
~(~)~)
(33)
2
----
in
Z~,[xl, ... ,
xv], where
~(1) = ~ rood pl.
(34)
Since the GCD in (32) is unit normal (in this case, monic) by definition, it follows
that lc (~(i)) = ~)(i).
Since G I F1 and G l F2 in
Z[xl, ".
, xv],
we have Gv~ I F~", Gvi ] P~'), and therefore
Gpi [ G (~) in
Zp~[xl,
... , xv], where Gv~ = G mod pl. It follows immediately that
Journal of the Association for Computing Machinery, Vol. 18, No. 4, October 1971