Given a polynomial in $x,y$, I want to collect on $x,y$ and any products of these also. As given using Maple's collect with the distributed option.
Currently Mathematica will collect on $x$ then collect on $y$. But this is not what I want.
An example will explain. Given this
ClearAll["Global`*"]
eq = -x^6*y*c[5] + x^6*y*c[9] - x^5*y^2*c[4] + x^5*y^2*c[10] -
x^6*c[5] + x^6*c[9] - 2*x^5*y*c[4] + 2*x^5*y*c[10] + x^4*y^2*c[5] -
x^4*y^2*c[9] - x^5*c[4] - x^5*c[6] + x^5*c[8] + x^4*y*c[1] -
x^4*y*c[3] - 2*x^4*y*c[7] + 2*x^3*y^2*c[2] - 2*x^3*y^2*c[4] -
x^3*y^2*c[8] + x^2*y^3*c[3] - x*y^4*c[4] + x^4*c[1] - x^4*c[3] -
2*x^3*y*c[6] + 3*x^2*y^2*c[1] - 2*x^2*y^2*c[3] - y^4*c[3]
If I just collect on x,y
this is the result
Collect[eq,{x,y}]
What I want is to collect on anything involving $x,y$ or products of these. This is what Maple's distributed option allows:
eq := -x^6*y*c[5] + x^6*y*c[9] - x^5*y^2*c[4] + x^5*y^2*c[10] - x^6*c[5] + x^6*c[9]
- 2*x^5*y*c[4] + 2*x^5*y*c[10] + x^4*y^2*c[5] - x^4*y^2*c[9] - x^5*c[4] - x^5*c[6]
+ x^5*c[8] + x^4*y*c[1] - x^4*y*c[3] - 2*x^4*y*c[7] + 2*x^3*y^2*c[2] - 2*x^3*y^2*c[4]
- x^3*y^2*c[8] + x^2*y^3*c[3] - x*y^4*c[4] + x^4*c[1] - x^4*c[3] - 2*x^3*y*c[6]
+ 3*x^2*y^2*c[1] - 2*x^2*y^2*c[3] - y^4*c[3];
collect(eq,[x,y],distributed)
You see the difference. The reason I wanted this, is to be able to set equations of all coefficients of anything thing that has $x$ or $y$ in order to solve for the unknowns $c_i$. The output given by Maple makes this much easier.
Here is another example to make it more clear
ClearAll["Global`*"]
eq=(-x^3)*a[1] - x*y*a[1] - x^4*a[2] - 2*x^2*y*a[2] - y^2*a[2] + (-x^2 + y)*(a[0] + x*a[1] + y*a[2]) + x^3*b[1] + x*y*b[1] + x^2*b[2] - x*(b[0] + y*b[1] + x*b[2]) == 0
Collect[eq,{x,y}]
Compare to
eq:=(-x^3)*a[1] - x*y*a[1] - x^4*a[2] - 2*x^2*y*a[2] - y^2*a[2] + (-x^2 + y)*(a[0] + x*a[1] + y*a[2]) + x^3*b[1] + x*y*b[1] + x^2*b[2] - x*(b[0] + y*b[1] + x*b[2]) = 0;
collect(eq,[x,y],distributed)
The question is: How to obtain the same output as Maple's in this case?