I'd like to use the Table command without defining n, so that I can have a list of n arguments.

It is possible for the Sum command, but I guess not for the Table command, or is it? Something like

n = 5; eSO = Table[e[i], {i, 1, n}]; ebar[1] = EBAU - Sum[ebar[i], {i, 2, n}]; 
a[1] = A - Sum[a[i], {i, 2, n}]; b[1] = B - Sum[b[i], {i, 2, n}];

Cost = Table[1/2/a[i]*(ebar[i] - e[i])^2 + b[i]*(Sum[e[i], {i, n}])^2 /2, {i, 1, n}];

FOC = Table[D[Sum[Cost[[i]], {i, n}] == 0, e[i]], {i, 1, n}];

solsSO = eSO /. Solve[FOC, eSO];

solsSO = Flatten[solsSO];

ESO = Simplify[Sum[solsSO[[i]], {i, n}]]

but a bit more complicated in the end.

  • $\begingroup$ If you want that your m is not fixed but variable you could try something like: wi=Table[Table[Sin[i],{i,1,m}],{m,1,10}] $\endgroup$
    – partial81
    Commented Jun 25, 2012 at 13:27
  • $\begingroup$ I'm not sure I understand you correctly. Are you looking for this: Table[w[i], {i, {1, 2, 4, 3, 7, 2, 11}}], i.e. calling Table with a list of predefined index values? $\endgroup$ Commented Jun 25, 2012 at 13:30
  • $\begingroup$ Id like a list with dimension n, so id get. {w[1],w[2],...,w[n-1],w[n]} $\endgroup$
    – Max M
    Commented Jun 25, 2012 at 13:51
  • 2
    $\begingroup$ You might like to have a look at this question, which demonstrates how to represent indeterminate-length (or infinite) lists in Mathematica. $\endgroup$ Commented Jun 25, 2012 at 15:46
  • 1
    $\begingroup$ I can't think of a way of doing this atm, but you might consider changing the title of your post to attract more attention. As I see it, the problem boils down to solving a system of equations with a indeterminate number of variables. $\endgroup$
    – sebhofer
    Commented Jun 27, 2012 at 7:48

1 Answer 1


It's not possible because it makes as much sense as wanting to have list of n elements with n being undefined. The most similar thing you can do is to have a symbolic representation of that, that evaluates to what you want when n gets a numeric value. For that, you can either define your own

symbolicTable[exp_, it:{_, __?NumericQ| _List}]:=Table[exp, it]

If you then use symbolicTable just like Table, it will only evaluate when the iterator bounds are numeric and remain unevaluated when they are not.

ooor, just turn off the warning message you get when you try to use Table with a non-numeric argument

  • $\begingroup$ Thx for you reply, but does this really help me with my problem? Maybe, I dont really understand your proposal. I still wont be able to have a list with n arguments then, will I? $\endgroup$
    – Max M
    Commented Jun 25, 2012 at 13:23
  • 1
    $\begingroup$ @Max: we might be more helpful if you tell us your actual problem, that is, the problem that requires this construction you speak of. $\endgroup$ Commented Jun 25, 2012 at 13:25
  • $\begingroup$ Its a rather simple optimization in economics. n would be the number of countries for which I have some cost function over which i minimize. Therefore I d like to have a list for the n countries where each argument represents one country, then do the differentiation and solve it. (still haveing trouble using minimize or sth similar). I can understand if that doesnt work since the program probably needs appropiate bounds for the list and the differentiation. if wi = Table[w[i], {i, 1, m}] is already not possible then the rest wont be either, i guess. $\endgroup$
    – Max M
    Commented Jun 25, 2012 at 13:38
  • $\begingroup$ @MaxM So do you want to do an analytical or a numerical calculation? $\endgroup$
    – sebhofer
    Commented Jun 25, 2012 at 14:03
  • 1
    $\begingroup$ @MaxM, I don't think Table can be used like that for analytical problems. You probably have to adapt your question giving more specifics of the problem at hand, to get real help $\endgroup$
    – Rojo
    Commented Jun 25, 2012 at 14:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.