Modular Gcd Algorithms in $ {\mbox{${\mathbb{Z}}$}}[x]$

Remark 13   Algorithm 1 computes the gcd $ h$ of two primitive polynomials $ f,g \in {\mbox{${\mathbb{Z}}$}}[x]$ . Before proving this algorithm, let us check that all its computations are well defined. Consider an iteration of the loop. We assume that we have a source of primes large enough. Given a prime $ p$ from this source the following polynomials are computed The only points to clarify are the equalities $ f^{\ast} \, w \equiv b \, f \mod{p}$ and $ g^{\ast} \, w \equiv b \, g \mod{p}$ . They hold since $ w$ is the gcd $ \overline{f}$ and $ \overline{g}$ which implies that $ w$ divides $ b \, f \mod{p}$ and $ b \, g \mod{p}$ .

Algorithm 1  

\fbox{
\begin{minipage}{10 cm}
\begin{description}
\item[{\bf Input:}] primitive...
...\\
\> {\bf return} {\rm normal}({\rm pp}($w$)) \\
\end{tabbing}\end{minipage}}

Proof. It is sufficient to see that

$\displaystyle {\Vert f^{\ast} \Vert}_1 \, {\Vert w \Vert}_1 \ \leq \ B \ \ \ \ {\rm and} \ \ \ \ {\Vert g^{\ast} \Vert}_1 \, {\Vert w \Vert}_1 \ \leq \ B$ (99)

both hold iff $ {\rm normal}({\rm pp}($ w$ )) = h$ . If the conditions hold then

$\displaystyle {\Vert f^{\ast} w \Vert}_{\infty} \ \leq \ {\Vert f^{\ast} w \Vert}_1 \ \leq \ {\Vert f^{\ast} \Vert}_1 \, {\Vert w \Vert}_1 \ \leq \ B < p/2$ (100)

Moreover from the algorithm computations we have

$\displaystyle {\Vert b \, f \Vert}_{\infty} \ < \ p/2$ (101)

and

$\displaystyle f^{\ast} \, w \ \equiv \ b \, f \mod{p}$ (102)

Relations (100) and (101) imply that every coefficient $ c$ of $ f^{\ast} \, w - b \, f$ satisfies $ -p < c < p$ . Whereas Relation (102) tells us that every coefficient $ c$ of $ f^{\ast} \, w - b \, f$ is a multiple of $ p$ . Therefore we have

$\displaystyle f^{\ast} \, w \ = \ b \, f$ (103)

Similarly we have

$\displaystyle g^{\ast} \, w \ = \ b \, g$ (104)

This implies that $ w$ divides $ {\gcd}(b \, f, b \, g)$ . Hence the primitive part of $ w$ divides that of $ {\gcd}(b \, f, b \, g)$ which is $ h$ . On the other hand Therefore $ {\rm pp}(w)$ and $ h$ have the same degree and are in fact equal up to a sign. Conversely assume that $ {\rm normal}({\rm pp}($ w$ ))$ is $ h$ . Recall that $ w$ and $ {\nu}$ have the same degree. Then the polynomials $ {\nu}$ and $ h$ have the same degree too. Hence by virtue of Theorem 3 we have

$\displaystyle \overline{{\alpha}} \, {\nu} \ = \ \overline{h}$ (105)

where $ {\alpha} = {\rm lc}(h)$ . Since $ {\alpha}$ divides $ b$ let $ {\beta}$ be such that $ b = {\alpha} \, {\beta}$ . Hence we have

$\displaystyle w \ \equiv \ {\beta} \, h \ \equiv \ b \, {\nu} \mod{p}$ (106)

Now by construction we have

$\displaystyle {\Vert w \Vert}_{\infty} \ < \ p/2$ (107)

Moreover Corollary 4 states that

$\displaystyle {\Vert h \Vert}_{\infty} \ \leq \ (n + 1)^{1/2} \, 2^{n} \, {\Vert f \Vert}_{\infty}$ (108)

which implies

$\displaystyle {\Vert {\beta} \, h \Vert}_{\infty} \ \leq \ B \ < \ p/2.$ (109)

Relations (105), (106) and (107) imply

$\displaystyle w \ = \ {\beta} \, h$ (110)

Since $ h$ divides $ f$ and $ g$ we deduce from Relation (109) that $ w$ divides $ b \, f$ and $ b \, g$ . Hence there exist polynomials $ \widehat{f}$ and $ \widehat{g}$ such that

$\displaystyle \widehat{f} \, w \ = \ b \, f \ \ \ \ {\rm and} \ \ \ \ \widehat{g} \, w \ = \ b \, g$ (111)

Corollary 4 applied to $ (\widehat{f}, w)$ (as factors of $ b \, f$ ) and $ (\widehat{g},w)$ (as factors of $ b \, g$ ) shows to

$\displaystyle {\Vert \widehat{f} \Vert}_1 \, {\Vert w \Vert}_1 \ \leq \ B \ \ \ \ {\rm and} \ \ \ \ {\Vert \widehat{g} \Vert}_1 \, {\Vert w \Vert}_1 \ \leq \ B$ (112)

Finally, it follows from the way $ f^{\ast}$ and $ g^{\ast}$ are computed that we have in fact

$\displaystyle \widehat{f} \ = \ f^{\ast} \ \ \ \ {\rm and} \ \ \ \ \widehat{g} \ = \ g^{\ast}$ (113)

and we proved that Relation (99) holds! $ \qedsymbol$

Remark 14   During the proof of Algorithm 1 between Relation (105) and Relation (110) we have established the following proposition which will lead to an improved algorithm.

Proposition 8   Let $ f, g, h, p, {\nu}, w$ be as in Algorithm 1. Let $ {\alpha}$ be the lading coefficient of $ h$ . Then we have

$\displaystyle {\deg}(h) \ = \ {\deg}({\nu}) \ \ \Rightarrow \ \ h \ = \ {\rm pp}(w).$ (114)

Proof. From Theorem 3 and $ {\deg}(h) \ = \ {\deg}({\nu})$ we derive Relation (105). Together with the fact that $ {\alpha}$ divides $ b$ and the definition of $ w$ this leads to Relation (106). Then Relations (105), (106) and (107) imply Relation (110) which shows $ h \ = \ {\rm pp}(w)$ . $ \qedsymbol$

Remark 15   From Theorem 3 we know that there are only a finite number of prime $ p$ for which the relation $ {\deg}(h) \ = \ {\deg}({\nu})$ does not hold Moreover for those prime such $ {\deg}(h) \ \neq \ {\deg}({\nu})$ the polynomial $ w$ has a higher degree than $ h$ . Hence we can simply Algorithm 1 into Algorithm 2. as follows.

Algorithm 2  

\fbox{
\begin{minipage}{10 cm}
\begin{description}
\item[{\bf Input:}] primitive...
... {\bf and} $w \mid g$\ \\
\> {\bf return} $w$\ \\
\end{tabbing}\end{minipage}}

Remark 16   We aim now to realize the following improvements. This leads to Algorithm 3

Algorithm 3  

\fbox{
\begin{minipage}{12 cm}
\begin{description}
\item[{\bf Input:}] primitive...
...n} $h$\ \\
\> \> $(m, g_m)$\ := $(m \, p, w)$\ \\
\end{tabbing}\end{minipage}}

Marc Moreno Maza
2008-01-07