# PolynomialExtendedGCD in 2 variables

Consider a field $R$ and the ring $A=R[y]$. Consider two polynomials $g,h\in A[x]$. I want to obtain $d=\gcd(g,h)\in A[x]$ and two polynomials $s,t\in A[x]$ satisfying the Bézout relation: $sg+th=d$. I used the following code:

g = x + y; h = x - y;

PolynomialExtendedGCD[g, h, x]

(* {1, {1/(2 y), -(1/(2 y))}} *)


As you see, the $s$ and $t$ given by Mathematica are $\frac{1}{2y}$ and $-\frac{1}{2y}$, which do not belong to $A[x]$ (it seems that the $y$ is treated as a number, not as an abstract variable corresponding to a polynomial). Is there any way to solve this problem?

EDIT: Okay, I think I know which my mistake was. To compute the gcd of two polynomials the coefficients have to be in a field, and $A$ is not a field. This makes me think of another question: $A$ is not a field, but for instance $A/(y-1)$ is (because $y-1$ is irreducible). Is it possible to compute the gcd of $g$ and $h$ and a Bézout relation as elements in $(R[y]/(y-1))[x]$? To sum up, I ask if there is some sort of code similar to

PolynomialExtendedGCD[g,h,x,Modulus->y-1]

• (1) Your second question amounts to doing the computation after substituting y->1. Which in turn reduces to an extended gcd in one variable, over the rationals. – Daniel Lichtblau Apr 30 '16 at 16:59
• (2) Yes, it's possible to get an extended gcd for polynomials in A[x] where A=Q[y]/<irreducible poly in y>. Would take some work, but its possible. For the specil case where the irreducible is linear, just do substitution as I noted in an earlier comment. – Daniel Lichtblau Apr 30 '16 at 17:01