[?] Define conditions for Table from an other Table?

Hello everyone,

I’v been working on Hilbert Cubes and I want to define on Mathematica the following:

\sum_{i=1}^d\epsilon_ ia_i for each \epsilon_ i taking value in {0,1}

For now I only managed to do it by defining the condition first like this (for d=4):

Table[{\epsilon_ i, 0, 1}, {i, 1, d}]

Wich returns: {{\epsilon_ 1, 0, 1}, {\epsilon_ 2, 0, 1}, {\epsilon_ 3, 0, 1}, {\epsilon_ 4, 0, 1}}

And then copy past it into:

Table[Sum[\epsilon_ ia_i , {i, 1, d}],{\epsilon_ 1, 0, 1}, {\epsilon_ 2, 0, 1}, {\epsilon_ 3, 0, 1}, {\epsilon_ 4, 0, 1}]

It works fine this way, but as I want to generate it for a large amount of values of d I would like to know if there is any way to not have to do the copy past manipulation.

I already tried several ways to do it (like including a For loop in the Table) but I have not managed to find a solution.

Thank you very much!

You can do it like this:

d=4
seq=Table[{Subscript[\[Epsilon], i],0,1},{i,d}]
Table[Sum[Subscript[\[Epsilon], i] Subscript[a, i],{i,d}],Evaluate[(Sequence@@seq)]]

or

Table[Sum[Subscript[\[Epsilon], i] Subscript[a, i],{i,d}],##]&@@seq

Note, however, that you should not use subscript for this purpose, it works, but it will sooner rather than later bite you. Try using the following notation:

 d=4
 seq=Table[{\[Epsilon][i],0,1},{i,d}]
 Table[Sum[\[Epsilon][i] a[i],{i,d}],Evaluate[(Sequence@@seq)]]
 Table[Sum[\[Epsilon][i] a[i],{i,d}],##]&@@seq

Subscript (and Superscript) should be thought of as a typographical construct! Not used for indexing!

Thank you very much it works perfectly!

And thank you for the tip, I’ll try to keep it in mind!