# Why isn't $\gcd(x^2+3x+2,x^2+x)=(x+1)$? [duplicate]

Excuse me for the confusing title. I was asked to find $$gcd(x^2+3x+2,x^2+x)$$

What i did is i factorized both polynomials $$x^2+x=(x+1)x$$

$$x^2+3x+2=(x+1)(x+2)$$

So i expected the gcd to be $$x+1$$

But using the euclidean algorithm i found out the gcd to be $$2x+2$$. Why is factorizing wrong? Is it because $$K[X]$$ is not factorial ? Would the euclidean algorithm also work if the polynomials are in $$\Bbb Z[X]$$ ???

## marked as duplicate by Bill Dubuque abstract-algebra StackExchange.ready(function() { if (StackExchange.options.isMobile) return; $('.dupe-hammer-message-hover:not(.hover-bound)').each(function() { var$hover = $(this).addClass('hover-bound'),$msg = $hover.siblings('.dupe-hammer-message');$hover.hover( function() { $hover.showInfoMessage('', { messageElement:$msg.clone().show(), transient: false, position: { my: 'bottom left', at: 'top center', offsetTop: -7 }, dismissable: false, relativeToBody: true }); }, function() { StackExchange.helpers.removeMessages(); } ); }); }); Oct 17 '18 at 19:40

• $\langle x^2 + 3x + 2, x^2 + x \rangle$ is not a principal ideal in $\mathbb{Z}[x]$ - despite the fact that $\mathbb{Z}[x]$ is in fact a UFD. On the other hand, if you take the gcd in $\mathbb{Q}[x]$ which is a PID then your two answers differ by a unit. – Daniel Schepler Oct 17 '18 at 18:45
• As Daniel said, $2x+2=2(x+1)$ and $x+1$ are not different as factorizations over $\mathbb Q[x]$. Nothing went wrong on that front. $K[x]$ is always factorial when $K$ is a field (or even if just $K$ is factorial.) – rschwieb Oct 17 '18 at 18:46
• So factorizing over $\Bbb Q [X]$ doesnt make sense ? – asddf Oct 17 '18 at 18:48
• @asddf No, it makes perfect sense. You'll have to elaborate on your line of thought for me to follow, because I don't know what would prompt you to ask such a thing. – rschwieb Oct 17 '18 at 18:49
• Ok i think i follow now, thank you – asddf Oct 17 '18 at 18:51

There is no unique gcd of two polynomials $$f,g\in \Bbb{Q}[X]$$. It is only unique up to a unit in $$\Bbb{Q}$$. So any of the polynomials $$c(X+1)$$ with $$c\neq 0$$ is a gcd of $$X^2+3X+2$$ and $$X^2+X$$.
Greatest common divisor of two polynomials in $$\Bbb Q[X]$$
Remark that $$x^2+3x+2-(x^2+x)=2x+2$$, this implies that $$(x+1)$$ is contained in $$(x^2+3x+2,x^2+x)$$, the fact that $$(x+1)$$ contains $$(x^2+3x+2,x^2+2)$$ results from the factorizations that you have provided. $$gcd(P(x),Q(x))=(P(x),Q(x))$$.