Symbolic simplification issue with exact division of polynomial by monomial

9 views (last 30 days)
I am writing a code and at some point I have an exact division of a polynomial with a monomial; however, simplification does not seem to work
Ex:
((x1 + y2 - x1*y2)*(- x2^2*y1 + x2^2 + x2*y1^2 - y1^2)*(2*x1 + x2 + y1 - x1*x2 - x1*y1 - 1))/(x2 - y1) does not simplify.
However, notice that the middle factor in numerator (- x2^2*y1 + x2^2 + x2*y1^2 - y1^2) is divisible by (x2-y1) and MATLAB; indeed, simplifies (- x2^2*y1 + x2^2 + x2*y1^2 - y1^2)/(x2 -y1) and gives x2 + y1 - x2*y1.
How could I get around this issue?

Accepted Answer

Star Strider
Star Strider on 25 Jun 2015
Sometimes, you have to lead it gently by the hand if you want it to do everything:
syms x1 x2 y1 y2
f = ((x1 + y2 - x1*y2)*(- x2^2*y1 + x2^2 + x2*y1^2 - y1^2)*(2*x1 + x2 + y1 - x1*x2 - x1*y1 - 1))/(x2 - y1);
f1 = expand(f);
f1 = simplify(collect(f1))
f1 =
(x1 + y2 - x1*y2)*(x2 + y1 - x2*y1)*(2*x1 + x2 + y1 - x1*x2 - x1*y1 - 1)
Is that the sort of result you want?

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!