For example, I have the following expression :
A( 2 x1 + B(y1 + y2) + 2 x2 )
How do I make the output look like this (grouping (x1 + x2) and (y1 + y2) terms together) ?
2A (x1 + x2) + A B (y1 + y2)
I don't know why Simplify doesn't group (x1 + x2) together but just gives:
A (2 x1 + 2 x2 + B (y1 + y2))
I can use Collect to get (y1 + y2) after Simplify but how about (x1 + x2) ?
Remember this is just a simple example, I would have a much more complicated terms involving (x1 + x2) and (y1 + y2), so a method with no operation on the constants (2A and A B) would be great.
expr = c x1 - c x2; expr//Simplifywill do. – b.gates.you.know.what Dec 01 '12 at 09:15Collect[expr,var, h]. You can apply it for much more involved algebraic expressions not worrying to play around with rules or whatever else. Look at my answer carefully. – Artes Dec 02 '12 at 02:52