# How to do a long division over a multivariate polynomial in Mathematica

Does anyone know how to do a long division of a multivariate polynomial over another multivariate polynomial to effectively find the remainder, hopefully with fewest terms and/or lowest degree, in Mathematica? Many thanks.

• PolynomialQuotient and PolynomialRemainder, the variable is specified as a 3rd argument. With this the multivariate case is probably covered. Apr 26, 2020 at 18:01
• @yarchik these do not work for 3rd argument is a list. It has to be one symbol there. PolynomialQuotient[x^2 + y, x + y^2, {x, y}] gives error PolynomialQuotient::ivar. I tried these first thing. Apr 26, 2020 at 18:36

Use PolynomialReduce for multivariable polynomials.
p1 = x^3 - 2 x^2 - 4 + y^2;

• Very nice, although I cannot think of an example where for the 2nd argument consisting of only one polynomial PolynomialReduce would give a different answer from PolynomialQuotientReminder. That is even confirmed with a screenshot of the doc page. Apr 26, 2020 at 18:48
• @DanielLichtblau Indeed, you are riight, consider division of $p(x,y)=x^2+xy^2+y^4$ over $q(x,y)=x+y^2$. Depending what variable is selected, the result of $p/q$ is different: for $x$: $x^2+xy^2+y^4=x(x+y^2)+y^4$ and for $y$: $x^2+xy^2+y^4=y^2(x+y^2)+x^2$. Apr 27, 2020 at 7:17