I have an expansion involving N factors:

(a[0][0] + a[0][1]) (a[1][0] + a[1][1]) (a[2][0] + a[2][1]) ... (a[N-1][0] + a[N-1][1])
for which I'm trying to find general expressions for the 2^N terms involved when this is all multiplied out. Getting an expression for two of the terms is straightforward when the 2nd indices of the a coefficients are the same:
$C[0] = 1; $C[$N-1] = 1; for ($i=0; $i<$N; $i++) { $C[0] *= $a->[$i]->[0]; $C[$N-1] *= $a->[$i]->[1]; }
but I'm stuck on the problem of getting the other terms. Can someone see a way to do this? Thanks.

UPDATE
Just to clarify the notation, what's desired is expressions for the 2**N coefficients of the expansion. For example, for N = 2 factors and 2**N = 4 terms:

(a[0][0] + a[0][1]) * (a[1][0] + a[1][1]) = C[0] + C[1] + C[2] + C[3], where C[0] = a[0][0] * a[1][0] C[1] = a[0][0] * a[1][1] C[2] = a[0][1] * a[1][0] C[3] = a[0][1] * a[1][1]
No meaning is intended for the order of the indices of the C array. There's a number of approaches suggested below that will get me going - thanks to all who responded!


In reply to Obtaining terms in an expansion by randyk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.