# [✓] Transform an expression to a certain form?

GROUPS:
 Hi, in my current project i evaluate large sums of the form:in the most cases f(i,k,n)=0 so im left with expressions of the form b*a[3]*a[4] + c*a[4]*a[3] + ... what i want are expresions of the form like: (b+c)*a[3]* a[4] Sometimes Simplify or FullSimplify is doing the job sometimes not...An example of what such an result look like is attached.Not my plan was to go through the expression and find all components which are proportional to a[i]*a[k] and sum up the prefactors, but i cant figure out a nice way of doing that.Does someone have an idea how to put the expression in the right form?Many thanks in advance!!! Attachments:
 Daniel Lichtblau 2 Votes e = (5 Sqrt[2/3] a^2 a[2] a[4])/(3 Sqrt[a^2 + g^2]) - ( 5 Sqrt[2/3] g^2 a[2] a[4])/(3 Sqrt[a^2 + g^2]) - ( 2 Sqrt[2/3] a g \[Pi] Sqrt[(a^2 + g^2) (4 g^2 + \[Pi]^2)] a[3] a[5])/((a^2 + g^2) (4 g^2 + \[Pi]^2)) - (a^2 a[6])/re - ( g^2 a[6])/re - (\[Pi]^2 a[6])/(3 re) + (a a[1] a[7])/Sqrt[6] + ( Sqrt[3/2] g \[Pi] a[1] a[8])/Sqrt[4 a^2 + 4 g^2 + \[Pi]^2] + ( a a[7] a[9])/Sqrt[6] + (Sqrt[3/2] g \[Pi] a[8] a[9])/Sqrt[ 4 a^2 + 4 g^2 + \[Pi]^2]; Separate out the a variables (but not a itself) and use Collect: avars = Cases[Variables[e], _a]; Collect[e, avars] ((5 Sqrt[2/3] a^2)/(3 Sqrt[a^2 + g^2]) - (5 Sqrt[2/3] g^2)/( 3 Sqrt[a^2 + g^2])) a[2] a[4] - ( 2 Sqrt[2/3] a g \[Pi] Sqrt[(a^2 + g^2) (4 g^2 + \[Pi]^2)] a[3] a[5])/((a^2 + g^2) (4 g^2 + \[Pi]^2)) + (-(a^2/re) - g^2/ re - \[Pi]^2/(3 re)) a[6] + a[1] ((a a[7])/Sqrt[6] + (Sqrt[3/2] g \[Pi] a[8])/Sqrt[ 4 a^2 + 4 g^2 + \[Pi]^2]) + (a a[7] a[9])/Sqrt[6] + ( Sqrt[3/2] g \[Pi] a[8] a[9])/Sqrt[4 a^2 + 4 g^2 + \[Pi]^2]