3

Suppose I know that I can find the $\gcd$ of two integers with the Euclidean algorithm. What is the 'extension' so I can use this method also for polynomials?

Edit: I found an easy answer with less rigor which is approachable without knowledge of matrices:

https://mathsci2.appstate.edu/~cookwj/sage/algebra/Euclidean_algorithm-poly.html

also the first 3 subchapters of

https://www.whitman.edu/mathematics/higher_math_online/chapter03.html

Bill Dubuque
  • 272,048
New2Math
  • 1,265
  • 3
    It is pretty much the same algorithm. Just instead of dividing integers with remainder you have to divide polynomials with remainder. – Mark Mar 08 '19 at 16:01
  • 1
    Note that the Euclidean algorithm doesn't work for polynomials with integer coefficients (try using the algorithm to deduce $\gcd(x, 2) = 1$). You need to have polynomials over a field, like the rational numbers, or the real numbers. – Arthur Mar 08 '19 at 16:03
  • 1
    All we need that the algorithm will always terminate, which is obvious considering the degree of the residue polynomial. If you have found the $\gcd$, you can create Bezout's idendity completely analogue to the integer-case. – Peter Mar 08 '19 at 16:03
  • As an aside, carrying out Peter's suggestion will also give you the proof that partial fraction expansion always works, which you were asked to take for granted in calculus. – saulspatz Mar 08 '19 at 16:06
  • Note that you don't need to know anything about matrices to use the method in my answer (indeed there are no matrices there). When you are first learning the method you may find it easier to work directly with the equations $, h_i =\color{#c00}{ a_i} f +\color{#0a0}{ b_i} g,$ instead of their coefficient vectors $\langle \color{#c00}{a_i}, ,\color{#0a0}{b_i}\rangle.,$ It may be easier to start with some simple integer (vs. polynomial) problems. If anything in my answer is not clear then please feel welcome to ask questions in comments. – Bill Dubuque Mar 09 '19 at 23:42
  • As @Arthur alluded to, you need a Euclidean domain. While $\Bbb Z$ is a Euclidean domain, $\Bbb Z[x]$ is not. If you have a field $k$, then $k[x]$ is a Euclidean domain. – calc ll Feb 06 '23 at 20:28

2 Answers2

3

The extended Euclidean GCD algorithm for polynomials over a field works the same way as it does for integers. As for integers, it is usually much easier and less error prone to not do it backwards but rather in forward augmented-matrix form, i.e. propagate forward the representations of each remainder as a linear combination of the gcd arguments (vs. compute them in backward order by back-substitution), e.g. from this answer, we compute the Bezout equation for $\gcd(f,g)\,$ over $\Bbb Q$.

$\!\begin{eqnarray} [\![1]\!]&& &&f = x^3\!+2x+1 &\!\!=&\, \left<\,\color{#c00}1,\ \ \ \ \color{#0a0}0\,\right>\quad {\rm i.e.}\ \qquad f\, =\, \color{#c00}1\cdot f\, +\, \color{#0a0}0\cdot g\\ [\![2]\!]&& &&\qquad\ \, g =x^2\!+1 &\!\!=&\, \left<\,\color{#c00}0,\ \ \ \ \color{#0a0}1\,\right>\quad{\rm i.e.}\ \qquad g\, =\ \color{#c00}0\cdot f\, +\, \color{#0a0}1\cdot g\\ [\![3]\!]&:=&[\![1]\!]-x[\![2]\!]\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! &&\qquad\qquad\ \ \:\! x+1 \,&\!\!=&\, \left<\,\color{#c00}1,\,\color{#0a0}{-x}\,\right>\ \ \ \ {\rm i.e.}\quad x\!+\!1 =\, \color{#c00}1\cdot f\ \color{#0c0}{-x}\cdot g\\ [\![4]\!]&:=&[\![2]\!]+(1\!-\!x)[\![3]\!]\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\!\! &&\qquad\qquad\qquad\ 2 \,&\!\!=&\, \left<\,\color{#c00}{1-x},\,\ \color{#0a0}{1-x+x^2}\,\right>\\ \end{eqnarray}$

Therefore the prior line yields $\ 2\, =\, (\color{#c00}{1\!-\!x})f + (\color{#0a0}{1\!-\!x\!+\!x^2})g\ \ \ $ [Bezout equation]

Normalizing to a monic gcd: $\,\ \ \ 1\, =\, \dfrac{\color{#c00}{1\!-\!x}}{2}\,f \,+ \dfrac{\color{#0a0}{1\!-\!x\!+\!x^2}}2\,g\,\ $ by scaling above by $1/2$.

Computing modular inverses from the Bezout equation works the same as for integers, e.g. reducing prior Bezout $\!\bmod g\Rightarrow f^{-1}\equiv{\large \frac{\color{#c00}{1-x}}2}\pmod{\!g}$.

The proof is also the same as for integers - by descent using (euclidean) division with remainder. The set $I = fR[x]+gR[x]$ of polynomials of form $\, a f + b g $ is an ideal, i.e. is closed under addition and scaling, so it is closed under remainder = mod, since that is a composition of such operations: $f_i\bmod g_i = f_i - q\, g_i.\,$ So the least degree $0\neq d\in I$ divides every $h\in I$ (else $0\neq h\bmod d\in I\,$ has smaller degree than $d).\,$ So $\,f,g\in I\,\Rightarrow\, d\,$ is a common divisor of $\,f,g,\,$ necessary greatest by $\, c\mid f,g\,\Rightarrow\, c\mid d\!=\! a f + b g,\,$ so $\,\deg c\le \deg d.\,$ To force $d$ unique (over a field) usually the convention is to scale it to be monic (lead coef $=1),\,$ as we did above.

This algorithm is an efficient way to search the set $I$ for a polynomial $\,d\neq 0\,$ of minimal degree, while also keeping track of each element's representation as a linear combination of $\,f\,$ and $\,g.\,$ The proof shows further that $\,d\,$ is the gcd of all elements of $I$.

The same ideas work for any Euclidean domain (i.e. enjoying division with (smaller) remainder).

Remark $ $ Generally (for hand calculations) the above method is much less error-prone than the alternative commonly presented "back-substitution" method (further it is simpler to memorize).

This is a special-case of Hermite/Smith row/column reduction of matrices to triangular/diagonal normal form, using the division/Euclidean algorithm to reduce entries modulo pivots. Though one can understand this knowing only the analogous linear algebra elimination techniques, it will become clearer when one studies modules - which, informally, generalize vector spaces by allowing coefficients from rings vs. fields. In particular, these results are studied when one studies normal forms for finitely-generated modules over a PID, e.g. when one studies linear systems of equations with coefficients in the (non-field!) polynomial ring $\rm F[x],$ for $\rm F$ a field, as above.

Bill Dubuque
  • 272,048
  • The greatest common Divisor $g$ for two polynomials $(f,h)$ is the polynomial for which we have if $d|f$ and $d|h$ then also $h|g$. Just like the gcd for two integers. Now to prove the euclidian algorithm for two polynomials I first have to prove just like for the integers if $a\cong c \mod b$ then $\gcd(a,b)= \gcd(b,c)$. The $mod$ operator is in this case the euclidian Division like you have said. Congruence means that the remainder is the same for $a$ and $c$. Therefore $b|a-c\Rightarrow c=a-yb$ and $a=c+yb$ If $d$ is a common dicisor for $a,b$ then also for c. Same for $b,c$ and a – New2Math Mar 10 '19 at 12:19
  • Then the euclidian algorithm to compute the greatest common Divisor for $f,h$ can be proved by saying $\deg(f)\geq\deg(h)$ and then calculating $f\mod h = qh+r_1$ Then since $r_1\cong f\mod h$ and $\deg r_1 < \deg h$ one can prove by induction that the algorithm terminates $i.e r_k=0$ for some $k$ then $\gcd(r_{k-1},0)=r_{k-1}$. One can then prove by induction that every $r_i$,i.e the $\gcd$ can be expressed as a linear combination of $f$ and $h$ – New2Math Mar 10 '19 at 12:33
  • Can you explain what is the difference between $\mathbb{Z}_3$ and $\mathbb{Q}$ in your example? – New2Math Mar 10 '19 at 13:01
  • @New2Math In this case the only difference was in the last equation (using $,2\equiv -1\pmod{3}.,$ I changed it to do the gcd over $\Bbb Q$ so it doesn't require any knowledge of modular arithmetic (it still works fine $\bmod 3$ using $,1/2\equiv 1/(-1)\equiv -1)\ $ – Bill Dubuque Mar 10 '19 at 15:48
  • @BillDubuque what is the correct formulation of this algorithm when working over a domain? For example the polynomials $x^2+7,x^3+3x+6\in \mathbb Z[x]$ admit $74$ as a gcd with respective coefficients $-2x^2-3x+8,2x+3$. I found this by row-reducing the Sylvester matrix and I think only the domain property of $\mathbb Z$ was used. I'd like to say "the" rank of the Sylvester matrix is the degree of the gcd, but I heard rank is not inherently defined for matrices over domains. Should it be the "minimal rank"? – Arrow Oct 21 '23 at 19:39
  • @Arrow The above method works for PIDs, not general domains. – Bill Dubuque Oct 21 '23 at 19:52
2

Just an example, showing where the fractions show up. I like doing the extended part, i.e. finding the Bezout expression, using the formalism of continued fractions. The magenta expressions are the "partial quotients"

$$ \left( 5 x^{4} + 4 x^{3} + 3 x^{2} + 2 x + 1 \right) $$

$$ \left( 2 x^{3} + 3 x^{2} + 4 x + 5 \right) $$

$$ \left( 5 x^{4} + 4 x^{3} + 3 x^{2} + 2 x + 1 \right) = \left( 2 x^{3} + 3 x^{2} + 4 x + 5 \right) \cdot \color{magenta}{ \left( \frac{ 10 x - 7 }{ 4 } \right) } + \left( \frac{ - 7 x^{2} - 14 x + 39 }{ 4 } \right) $$ $$ \left( 2 x^{3} + 3 x^{2} + 4 x + 5 \right) = \left( \frac{ - 7 x^{2} - 14 x + 39 }{ 4 } \right) \cdot \color{magenta}{ \left( \frac{ - 8 x + 4 }{ 7 } \right) } + \left( \frac{ 120 x - 4 }{ 7 } \right) $$ $$ \left( \frac{ - 7 x^{2} - 14 x + 39 }{ 4 } \right) = \left( \frac{ 120 x - 4 }{ 7 } \right) \cdot \color{magenta}{ \left( \frac{ - 1470 x - 2989 }{ 14400 } \right) } + \left( \frac{ 34673}{3600 } \right) $$ $$ \left( \frac{ 120 x - 4 }{ 7 } \right) = \left( \frac{ 34673}{3600 } \right) \cdot \color{magenta}{ \left( \frac{ 432000 x - 14400 }{ 242711 } \right) } + \left( 0 \right) $$ $$ \frac{ 0}{1} $$ $$ \frac{ 1}{0} $$ $$ \color{magenta}{ \left( \frac{ 10 x - 7 }{ 4 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ 10 x - 7 }{ 4 } \right) }{ \left( 1 \right) } $$ $$ \color{magenta}{ \left( \frac{ - 8 x + 4 }{ 7 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ - 20 x^{2} + 24 x }{ 7 } \right) }{ \left( \frac{ - 8 x + 4 }{ 7 } \right) } $$ $$ \color{magenta}{ \left( \frac{ - 1470 x - 2989 }{ 14400 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ 1050 x^{3} + 875 x^{2} + 6438 x - 6300 }{ 3600 } \right) }{ \left( \frac{ 420 x^{2} + 644 x + 3173 }{ 3600 } \right) } $$ $$ \color{magenta}{ \left( \frac{ 432000 x - 14400 }{ 242711 } \right) } \Longrightarrow \Longrightarrow \frac{ \left( \frac{ 18000 x^{4} + 14400 x^{3} + 10800 x^{2} + 7200 x + 3600 }{ 34673 } \right) }{ \left( \frac{ 7200 x^{3} + 10800 x^{2} + 14400 x + 18000 }{ 34673 } \right) } $$ $$ \left( 5 x^{4} + 4 x^{3} + 3 x^{2} + 2 x + 1 \right) \left( \frac{ 420 x^{2} + 644 x + 3173 }{ 34673 } \right) - \left( 2 x^{3} + 3 x^{2} + 4 x + 5 \right) \left( \frac{ 1050 x^{3} + 875 x^{2} + 6438 x - 6300 }{ 34673 } \right) = \left( 1 \right) $$

Will Jagy
  • 139,541