Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
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}] – partial81 Jun 25 '12 at 13:27
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? – István Zachar Jun 25 '12 at 13:30
Id like a list with dimension n, so id get. {w[1],w[2],...,w[n-1],w[n]} – Max M Jun 25 '12 at 13:51
You might like to have a look at this question, which demonstrates how to represent indeterminate-length (or infinite) lists in Mathematica. – Oleksandr R. Jun 25 '12 at 15:46
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. – sebhofer Jun 27 '12 at 7:48

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

share|improve this answer
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? – Max M Jun 25 '12 at 13:23
@Max: we might be more helpful if you tell us your actual problem, that is, the problem that requires this construction you speak of. – J. M. Jun 25 '12 at 13:25
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. – Max M Jun 25 '12 at 13:38
@MaxM So do you want to do an analytical or a numerical calculation? – sebhofer Jun 25 '12 at 14:03
@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 – Rojo Jun 25 '12 at 14:13

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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