I'm not sure I understand the role of subscripts and superscripts in the Mathematica language. For me, the expression:

v={Subscript[v, x],Subscript[v, y],Subscript[v, z]}

is legitimate (where I will have used Ctrl+- to visually enter the subscripts actually). However, for Mathematica it isn't (I get "recursion depth of 1024 exceeded" error). Similarly if I define:


Then I get in return:

Out= Subscript[{a, b, c}, x]

So what do subscripts exist for if I cannot differentiate between variables that have the same "letter" but different subscripts (I.e. Subscript[v,x] and Subscript[v,y])? The same goes for superscripts I imagine.

Thank you!

  • $\begingroup$ Have you seen Indexed[]? $\endgroup$ – J. M.'s ennui Jul 24 '15 at 15:06
  • 1
    $\begingroup$ @MichaelE2 Exactly. I'm wondering what sub/superscripts are designed to do in Mathematica such that I don't try to "fit" them for a use they're not meant for. $\endgroup$ – space_voyager Jul 24 '15 at 15:45
  • 3
    $\begingroup$ I think they were designed to deliberately confuse newbies. $\endgroup$ – george2079 Jul 24 '15 at 15:45
  • 3
    $\begingroup$ Subscripts are for typesetting only; avoid them for most if not all programming endeavors. See also this FAQ, bullet 2. If you an unstoppable, strong urge to use them, have a look at the Notation package. $\endgroup$ – Sjoerd C. de Vries Jul 24 '15 at 16:43
  • 1
    $\begingroup$ @space_voyager I use them for formatting, e.g. they're convenient to use when generating log-tickmarks to get $10^0, 10^1, 10^2, ...$. Think of them as something that formats in a certain way but has absolutely no builtin meaning otherwise. $\endgroup$ – Szabolcs Jul 24 '15 at 16:56

I think the problem in your first line of code is that you're trying to set v to a structure which contains v, hence the recursion issue. Mathematica is indeed able to differentiate variables of the same letter and different subscripts. Note Subscript[v, x] == Subscript[v, y] evaluates False and

Subscript[v, x] = 5;
Subscript[v, y] = 4;
Subscript[v, x]
Subscript[v, y] 

will produce the output


So they do exist for both formatting and differentiating similar variables, they just require some care to use.

  • $\begingroup$ Thanks but see my answer to @MichaelE2 my question isn't about this specifically. But thank you anyway. $\endgroup$ – space_voyager Jul 24 '15 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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