I can't believe this hasn't been asked before but I can't find anything.
Is there a way to convince Simplify or FullSimplify to extract common factors from matrices as it does from sums?
Exhibit A:
{a/(2 c), b/(2 c), d/(2 c), e/(2 c)} // FullSimplify // FullSimplifygives
{a/(2 c), b/(2 c), d/(2 c), e/(2 c)}In reality, I have a 2x2 matrix, but the result is effectively the same. A solution to my problem should ideally not depend on the dimensions/layout of the (potentially nested) list.
Exhibit B:
a/(2 c) + b/(2 c) + d/(2 c) + e/(2 c) // FullSimplifygives
(a + b + d + e)/(2 c)
I did see this related question, but I'm just asking about rearranging, I don't actually need access to the polynomial GDC in a separate variable or anything, so I was wondering if this was possible with Simplify or FullSimplify somehow.



{a,b,c} xis not a "stable form", it would immediately evaluate to{a x, b x, c x}. The question is interesting, I'm just mentioning that it's not possible to keep the expression in this form. You'd have to store{a,b,c}andxseparately. – Szabolcs Jan 04 '15 at 17:48x+x, which evaluates immediately to2x, orSin[Pi]which evaluates to0. – Szabolcs Jan 04 '15 at 17:51PolynomialGDC. Feel free to close as duplicate. – Martin Ender Jan 04 '15 at 17:52Hold[{a, b} x]orHoldForm[{a,b} x], but held expressions aren't very suitable for algebraic manipulation.HoldFormis useful though for just displaying the expression in certain form that is easier for us humans to parse. – Szabolcs Jan 04 '15 at 17:55SimplifyandFullSimplify, but I vaguely recall that they make their decisions about what forms are "simplest" based on some sort of cost function, and that there have been previous questions asking about how to manipulate the cost function used bySimplifyin order to tailor the output to a particular form that was considered 'optimal' by the question-asker. Is there any way that cost-function modification could be applied here, or is that not possible? – DumpsterDoofus Jan 04 '15 at 18:09ComplexityFunction(which wouldn't be necessary) and theTransformationFunctions(which would), but because the result the OP was looking for auto-evaluates, it wouldn't be of any help. Theoretically you could include a transformation function that appliesHoldafter extracting the common factor, but sinceSimplifywon't be able to further transform held expressions, and since the factor extraction would need to be done manually anyway, it makes little sense to integrate this intoSimplify. – Szabolcs Jan 04 '15 at 18:21facMat[m_] := m /. mat : IgnoringInactive[{{f_ _ ..} ..}?MatrixQ] :> Inactivate[f (mat /. IgnoringInactive[f i_] :> i), Times]– Rojo Jan 05 '15 at 11:48