# What role to sub/superscripts play in Mathematica?

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:

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


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!

• Have you seen Indexed[]? – J. M. will be back soon Jul 24 '15 at 15:06
• @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. – space_voyager Jul 24 '15 at 15:45
• I think they were designed to deliberately confuse newbies. – george2079 Jul 24 '15 at 15:45
• 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. – Sjoerd C. de Vries Jul 24 '15 at 16:43
• @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. – 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

5
4


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

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