I need to find the gcd of two polynomials: $f(x) = x^4+1$ and $g(x)=x^2-1$ using the Euclidean algorithm.
Wolfram shows that the gcd is equal to $1$, but for some reason I don't get the same answer.
- First I divided $f(x)$ by $g(x)$ and got that the remainder is $2$.
- Then, I divided $g(x)$ by the remainder, $2$, and got a remainder of zero, hence concluding that the gcd is $2$.
What am I doing wrong?
If your polynomials are over $\mathbf{R}$, then a gcd of $1$ is equivalent to a gcd of $2$ (and any other nonzero real), because in general gcds are only well-defined up to associatedness, i.e. mutual divisibility.
The greatest common divisor of $f$ and $g$ is (in the case of polynomials) defined as a polynomial $d$ such that $d$ divides $f$ and $g$ and every divisor of $f$ and $g$ also divides $d$.
Thus, if we have another polynomial $e$ that is associated with $d$ (which means that $e|d$ and $d|e$), then we have $e|d|f$, $e|d|g$ and for every common divisor $z$ of $f$ and $g$ we have $z|d|e$, so $e$ is also a gcd of $f$ and $g$.
In your case you have two gcds of $1$ and $2$. Because $1\cdot 2 = 2$ and $2\cdot\frac12=1$ you have $1|2$ and $2|1$, so $1$ and $2$ are associated, thus if $1$ is a gcd, so is $2$ and vice versa.
Note that it is possible to normalize the gcd of polynomials by requiring the first nonzero coefficient to be $1$, which is what Wolfram|Alpha presumably does.