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?