1
$\begingroup$

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.

$\endgroup$
2
  • $\begingroup$ PolynomialQuotient and PolynomialRemainder, the variable is specified as a 3rd argument. With this the multivariate case is probably covered. $\endgroup$
    – yarchik
    Apr 26, 2020 at 18:01
  • 1
    $\begingroup$ @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. $\endgroup$
    – Nasser
    Apr 26, 2020 at 18:36

1 Answer 1

4
$\begingroup$

Use PolynomialReduce for multivariable polynomials.

p1 = x^3 - 2 x^2 - 4 + y^2;
p2 = x - 3 + y^2;
{q, r} = PolynomialReduce[p1, p2, {x, y}]

Mathematica graphics

from help it says

Mathematica graphics

$\endgroup$
3
  • 1
    $\begingroup$ 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. $\endgroup$
    – yarchik
    Apr 26, 2020 at 18:48
  • 3
    $\begingroup$ @yarchik One can get different results in the multivariate case by specifying a term order that is not lexicographic. $\endgroup$ Apr 26, 2020 at 21:08
  • $\begingroup$ @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$. $\endgroup$
    – yarchik
    Apr 27, 2020 at 7:17

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.