# Generating a list of symbolic coefficients [duplicate]

I am trying to do something which I assume should be very simple: I want to generate a list with symbolic coefficients that looks like this:

A = {a0, a1, a2, a3, ... , a20};


And I mean to do this a lot up to an arbitrary number, so I wouldn't want to type them all. So of course when I set one of them, say a1 = 5, then it should be updated in the list, so now:

A = {a0, 5, a2, a3, ... , a20};


I might just be missing an obvious Mathematica command here that does this... Is there a way to do such a thing?

-

## marked as duplicate by Sjoerd C. de Vries, Michael E2, halirutan, Yves Klett, ArtesApr 9 '13 at 16:26

You can use Symbol["a" <> ToString[#]] & /@ Range[20]. – b.gatessucks Apr 9 '13 at 12:49
Thanks, that exactly the line that I needed! (except that I used Range[0,20] as I start at 0, but never mind that) – Jelle Apr 9 '13 at 13:16
Other possible duplicates: this – Sjoerd C. de Vries Apr 9 '13 at 13:38

Depending on the problem you are having, it is maybe enough when you create a list of {a[0], a[1], a[2], a[3], ...}. This can be done with

Array[a, 10]


or, if you like Table

Table[a[i], {i, 10}]


If you really want to create an where n is a number, then you can use Symbol to convert a string to a symbol

Table[Symbol["a" <> ToString[i]], {i, 10}]


or, if you want definitely unassigned variables and you don't care which numbers they get

Table[Unique["a"], {10}]

-
Ah, thank you very much! The Symbol[] command was just what I needed! – Jelle Apr 9 '13 at 13:13
What about also mentioning ToExpression? – Yves Klett Apr 9 '13 at 14:19
@YvesKlett I assume it will be closed as dup soon and in the other post ToExpression is used. – halirutan Apr 9 '13 at 15:30
Yup. I voted for that but I think your answer is nice, short and useful anyway. – Yves Klett Apr 9 '13 at 15:57