If I have two polynomials $p(x),q(x)$, PolynomialGCD[p,q,x] can give me their greatest common divisor. But how to compute the polynomials $a(x),b(x)$ such that $d(x)=a(x)p(x)+b(x)q(x)$? I'm having trouble programming the division algorithm, but if someone is able to do that, I might be able to reverse engineer the steps to build a,b.


1 Answer 1


Use PolynomialExtendedGCD. Here's an example from the Mathematica documentation:

{f, g} = {2 x^5 - 2 x, (x^2 - 1)^2};
{d, {a, b}} = PolynomialExtendedGCD[f, g, x]
d == {f, g}.{a, b} // Simplify

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.