Given two polynomials, $f(x)$ and $g(x)$, I need to determine whether $f(x)$ is a factor of $g(x)$. Seems simple enough, and the way I initially did it was just checking if $f(x)$ is in a FactorList of $g(x)$:
MemberQ[Flatten[FactorList[ g[x] ]][[;; ;; 2]], f[x] ]
This almost works, however, when you consider something like $g(x)=x^4-1$ and $f(x)=x^2-1$, it should return true since $g(x) = f(x) (x^2+1)$. However, FactorList gives a list of irreducible polynomials, which doesn't include $x^2-1$.
So, how do I check if one polynomial is a factor of another in Mathematica?