Greatest Common Divisors, Resultants, and Discriminants
You can compute the greatest common divisor of two polynomials using the
function gcd. Here's an example:
You could also see that p and q have a factor in common by using the
function resultant:
The resultant of two polynomials vanishes precisely when they have a
factor in common. (In the example above we specified the variable with which
we wanted to compute the resultant because the polynomials could have
involved variables other than x.)