3
$\begingroup$

(This was a hard question to give a succinct title to, so feel free to edit it.)

When I divide polynomials, I would like Mathematica to NOT create negative powers of variables. For example:

expr = c*(p^2) + p^4 + c^2 + 2*p + 3*c + 1;
PolynomialQuotientRemainder[expr, c*(p^2) + c, p]
PolynomialQuotientRemainder[expr, c*(p^2) + c, c]

Results:

$\left\{\frac{p^2}{c}-\frac{1}{c}+1,c^2+2 c+2 p+2\right\}$

$\left\{\frac{c}{p^2+1}+\frac{p^2}{p^2+1}+\frac{3}{p^2+1},p^4+2 p+1\right\}$

I don't want fractions with variables in the quotients.

Desired result:

$\left\{1,c^2+2 c+p^4+2 p+1\right\}$

How can I accomplish this?

$\endgroup$
  • 6
    $\begingroup$ In[387]:= PolynomialReduce[c*(p^2) + p^4 + c^2 + 2*p + 3*c + 1, c*(p^2) + c, {c, p}] Out[387]= {{1}, 1 + 2 c + c^2 + 2 p + p^4} $\endgroup$ – Daniel Lichtblau Jan 13 '16 at 0:39
3
$\begingroup$

Daniel Lichtblau has supplied the answer in a comment: use PolynomialReduce, rather than PolynomialQuotientRemainder. As such:

PolynomialReduce[expr, c*(p^2) + c, {c, p}]
(* -> {{1}, 1 + 2 c + c^2 + 2 p + p^4} *)

which is the desired result.

$\endgroup$
  • $\begingroup$ Yeah, Daniel does that a lot. I wish there was an option to "Accept this Comment as the Answer". $\endgroup$ – Jerry Guern Jan 17 '16 at 20:18
  • 2
    $\begingroup$ From what I can tell, Daniel is not big on one-liner answers (he talks to me at times, which really unnerves his spouse). $\endgroup$ – Daniel Lichtblau Jan 18 '16 at 16:34
  • $\begingroup$ @Daniel lol --- $\endgroup$ – Mr.Wizard Feb 21 '17 at 7:45

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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