I was looking for an automated way to factor out common terms from a list.
Example (assuming n<1):
list={(1 + r^2)^(-1/2 + n/2) (1 + w^2)^(-1/2 - n/2) (1 + r^(1 - n) w^(1 + n)) x12^-n,
r^(1 - n) (1 + r^2)^(-1/2 + n/2) w^(1 + n) (1 + w^2)^(-1/2 - n/2) x12^-n,
(1 + r^2)^(-1/2 + n/2) (1 + w^2)^(-1/2 - n/2) x12^-n}
Expected output:
(1 + r^2)^(-1/2 + n/2) (1 + w^2)^(-1/2 - n/2) x12^-n { (1 +
r^(1 - n) w^(1 + n)) , r^(1 - n) w^(1 + n), 1 }
or
{ CommonFactor->(1 + r^2)^(-1/2 + n/2) (1 + w^2)^(-1/2 - n/2) x12^-n ,
{ (1 + r^(1 - n) w^(1 + n)) , r^(1 - n) w^(1 + n), 1 }}
There are some ways (Extract common factor from vector or matrix) to factor out common terms using PolynomialGCD, which works in most of the cases, however, in this case, it does not do it properly (probably due to the unknown n?)
Using their approach I get
{"CommonFactor" -> r^(-2 n) (1 + r^2)^(-(1/2) + n/2) (1 + w^2)^(-1 - n) x12^(-2n),
{r^(2 n) (1 + r^2)^(1/2 + 1/2 (-1 + n) - n/2) (1 + w^2)^(1/2 + n/2) (1 + r^(1 - n) w^(1 + n)) x12^n,
r^(1 + n) w^(1 + n) (1 + w^2)^(1/2 + n/2) x12^n,
r^(2 n) (1 + w^2)^(1/2 + n/2) x12^n}}
which is not the wanted behavior. Assuming[0<n<1 also does not help.
Is there any better way?
Intersection @@ list;) – Ben Izd May 06 '22 at 18:34list = Expand[list]norlist = {r x + r^(2 - n) y, r (x + 2 y)}. – Michael E2 May 06 '22 at 19:18Assuming n>1etc. Probably one has to make the expressions in a particular form (according to the requirement) and then applyIntersection. I find both a combination ofIntersection&PolynomialGCDuseful for some of my other cases similar to the one in the question. – BabaYaga May 07 '22 at 07:10TreeFormand realized that parts of the tree were identical. Once you expand this expression, the peculiarities of internalFullFormrepresentations would prohibit such a filtering in general as a structural intersection is being calculated, not a computational one. – Syed May 07 '22 at 07:20{a^-n (1+a^n b),b,a^-n}is one such example whereIntersectionfails, butPolynomialGCDworks as expected. But in theIntersectionway, although it can not find the common factor, it tries anyway to write the intersection. One would expect to return in such cases just a common factor1instead of errors and symbolical form of the common factor with intersection of terms. – BabaYaga May 13 '22 at 10:48PolynomialGCDand see if it helps. – Syed May 13 '22 at 11:10|| (AllTrue[list,Head[#] === Symbol &])in the condition iflist={a,b,c}which is also a problem forIntersection. – BabaYaga May 13 '22 at 15:41