Question: Reduce length of sum of products

I hope the solution is not too obvious...

My expression is

G1*P3 + G1*P5 + G1*P6 + G2*P3 + G2*P6 + G3*P2 + G3*P5 + G4*P2 + G4*P3 + G4*P5 + G4*P6 + G5*P2 + G5*P3 + G5*P5 + G5*P6 + G6*P3 + G6*P6 + G7*P2 + G7*P5 + G8*P2 + G8*P3 + G8*P5 + G8*P6

I want this to become as short (in terms of display characters) as possible. I tried simplify, which gives

(G1 + G2 + G4 + G5 + G6 + G8)*P3 + (G1 + G3 + G4 + G5 + G7 + G8)*P5 + (G1 + G2 + G4 + G5 + G6 + G8)*P6 + P2*(G3 + G4 + G5 + G7 + G8)

How do I get

(G1 + G2 + G4 + G5 + G6 + G8)*(P3+P6) + (G1 + G3 + G4 + G5 + G7 + G8)*P5 + (G3 + G4 + G5 + G7 + G8)*P2

which is shorter and which you can get from directly looking at the expression? The Terms Gi and Pj are just scalar variables as a placeholder. Using collect seems only to work on one variable.

Please Wait...