This works:

Table[Subscript[x, j], {j, 1, 10}]

But this doesn't:

x = Table[Subscript[x, j], {j, 1, 10}]

Giving this warning:

$RecursionLimit::reclim2: Recursion depth of 1024 exceeded during evaluation of Subscript[x, 1]. >>

Can someone explain why this happens?

Students can do this of course:


But what's the easiest way (for students just starting to use Mathematica) to enter x1, x2, through x100 and store them in the variable x?

  • 3
    $\begingroup$ You are defining x in terms of x; hence the error. Use Indexed[] instead. $\endgroup$ Commented Jun 23, 2016 at 19:22
  • 3
    $\begingroup$ Or do xs = Array[x, 100], which is how I would do it. If you insist on Subscripts, do xs = Array[Subscript[x,#]&, 100] $\endgroup$
    – march
    Commented Jun 23, 2016 at 19:55
  • 2
    $\begingroup$ Indexed or simply x[i] for the win. $\endgroup$ Commented Jun 23, 2016 at 20:29
  • $\begingroup$ @J.M. Can you please give me a complete line of code for the Indexed command, storing the answer in a variable, so I am sure of what you are suggesting? Thanks. $\endgroup$
    – David
    Commented Jun 23, 2016 at 21:33
  • $\begingroup$ Closely related: (22376). Also perhaps worth reading, including the various questions linked therein: (6511) $\endgroup$
    – Mr.Wizard
    Commented Sep 25, 2016 at 13:10

1 Answer 1


As others have said, you can't define a symbol in terms of its own DownValues or in terms of Subscripts of itself, so these both give recursion errors:

x = Table[x[n], {n, 5}]
x = Table[Subscript[x, n], {n, 5}]

I would suggest either of these workarounds:

x = Table[Symbol["x" <> IntegerString[n]], {n, 5}]
(* {x1, x2, x3, x4, x5} *)


xlist = Table[x[n], {n, 5}]
(* {x[1], x[2], x[3], x[4], x[5]} *)

That last one of course would work with subscripts too, although we try to discourage using subscripts for anything other than display formulas,

xlist = Table[Subscript[x, n], {n, 5}]

Mathematica graphics

  • $\begingroup$ I'd like to thank you and your colleagues for some excellent help. $\endgroup$
    – David
    Commented Jun 24, 2016 at 1:16
  • $\begingroup$ Jason, I marked this question as a duplicate. Please let me know if you disagree with that action. I noticed only after the final question here, though that is probably also a duplicate of others. $\endgroup$
    – Mr.Wizard
    Commented Sep 25, 2016 at 13:08

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