I'm trying to expand the following polynomial
Expand[ (A1 a1 + A2 a2 + A3 a3 + A4 a4 + A5 a5 + A6 a6 + A7 a7 + A8 a8)
(D1 a1 + D2 a2 + D3 a3 + D4 a4 + D5 a5 + D6 a6 + D7 a7 + D8 a8)
+ (H1 a1 + H2 a2 + H3 a3 + H4 a4 + H5 a5 + H6 a6 + H7 a7 + H8 a8)
(E1 a1 + E2 a2 + E3 a3 + E4 a4 + E5 a5 + E6 a6 + E7 a7 + E8 a8)]
and collect terms (for example, rewrite this as
(A1 D1 + ....+ H1 E1) a1^2 + (A1 D2 + ....) a1 a2 + (A1 D3 + ... ) a1 a3 + ...
+ (A8 D8 + ... + ) a8^2 )
where I am thinking of the capital letters A1, A2, ...., D1, D2, ... H1, H2, ..., E1, E2, ...
as some coefficients and a_i
's as variables.
I could do this by hand but what if, instead of having 8
variables and two terms, I have k
variables and n
terms? Expanding the products and collecting terms by going through all the monomials by hand are doable but probably not that clever.