# Find the greatest common divisor of pairs of polynomials

I'm trying to find the greatest common divisor of $$p(x)=7x^3+6x^2-8x+4$$ and $$q(x)=x^3+x-2$$ where both $p(x),q(x)\in\mathbb{Q}[x].$ And if $d(x)=gcd(p(x),q(x)),$ I need to find two polynomials $a(x),b(x)$ such that $d(x)=a(x)p(x)+b(x)q(x).$ I'm if both $p(x),q(x)\in\mathbb{Z},$ the gcd would be $1$, but I don't know how to find it in $\mathbb{Q}.$

First attempt, I used the euclidean algorithm. I find the gcd is $\frac{1}{76}x-\frac{5}{152}$ which is very weird (Maybe wrong). And I couldn't find $a(x),b(x).$

• use the euclidean algorithm. – Jorge Fernández Hidalgo Feb 12 '16 at 5:41
• @TheKindCat I know that for integers, but I don't know how it works for polynomials – Kelan Feb 12 '16 at 5:53
• Possible duplicate of Find the gcd of polynomials – ccorn Feb 12 '16 at 5:54
• @ccorn The answer in that question didn't give any idea about the first part, i.e. my question. – Kelan Feb 12 '16 at 6:19
• @Kelan You should probably include the details of your attempt with the Euclidean algorithm. Also, you'll need to read about the extended Euclidean algorithm. The fact that you have been assigned this question suggests that that method is probably explained somewhere in your course materials. – David Feb 12 '16 at 6:52

Took me quite a while and a few errors, anyway $$( 119 x^2 + 368 x + 400) q - (17 x^2 + 38 x + 61) p = -1044$$ so the gcd is $1.$ The way to do this is to calculate everything with integers, even though the gcd is not defined in $\mathbb Z[x],$ it is defined in $\mathbb Q[x].$ To get $1$ on the right hand side, divide every coefficient by $-1044.$
For example, the first step I did was $$p - 7 q = 6 x^2 - 15 x + 18$$
Then $$6 q = 6 x^3 + 6 x - 12$$ but $$x(p - 7 q) = 6 x^3 - 15 x^2 + 18 x$$ Subtraction gives $$(7x+6) q - x p = 15 x^2 - 12 x - 12$$ compare $$p - 7 q = 6 x^2 - 15 x + 18$$ AND SO ON