Why does the code (Mathematica version 10.0.2.0, Linux x86-64):
Subscript[Subscript[S,i],j] Subscript[Subscript[S,i],j] // Simplify
output the expression:
$(S_i)^2_j$
Is this the expected output? If so, why? And how can I prevent Simplify from touching the expression above if this is the correct behaviour?
Edit 1:
To be clear, what I mean is this: the output of the expression looks "ambiguous" to me. If I want to interpret the subscript as an operation on S, then the simplified expression is not equivalent to the original one. Why doesn't Mathematica output:
$(S_{ij})^2$
instead? Can I make Mathematica output this instead?
Edit 2:
This questions is not about the Mathematica code I posted above because I want to interpret the subscripts as a particular operation, and in the code above I can convert to a form that is handled better in calculations than subscripts. What I want to know is why Mathematica outputs the code as $(S_i)^2_j$, when my suggestion of $(S_{ij})^2$ seems more logical and "safer" (in the sense that it preserves more of the structure of the original form).
Edit 3:
To better display my intent, I'll explain that I want to interpret the index as notation for an operation, $d_i$ acting on an object $S$. In Mathematica I write it as d[S,i], but since I may have up to 6 (and potentially more) $d$ operations on one object, I want to display this more succinctly as $S_i$. To this effect I execute:
expr //. d[S_, i_] -> Subscript[S,i]
when displaying my expressions. A nice side effect is that I can also enter expressions in this notation by converting back to the functional form before I do my calculations proper:
expr = displayexpr //. Subscript[S_, i_] -> d[S,i]
(* calculations on expr... *)
Now, my expressions are long and multitudinous, so when I simplified expressions like
Subscript[Subscript[S,i],j] Subscript[Subscript[S,i],j]
I was given the output:
$(S_i)^2_j$
which threw me since at first glance it seems to tell me I have expressions of the form:
Subscript[Subscript[S,i]^2, j]
I can understand what Mathematica is doing, I just wonder if it is the best way to display its expressions...





FullFormof your output isPower[Subscript[Subscript[S, i], j], 2]. What would you expect the output to be? – Karsten7 Dec 07 '15 at 22:47HoldFormmight not be useful. – Zorawar Dec 07 '15 at 22:49Subscript[S, i, j]. This tutorial might be helpful. – Karsten7 Dec 07 '15 at 23:00Subscript[S,i,j]outputs: $S_{i,j}$ and I don't want the comma to appear since it's clutter and there will eventually be a lot of subscripts in my code :) Can I print an invisible comma by using theSubscriptfunction only once? – Zorawar Dec 07 '15 at 23:05Subscripts for calculations purposes; only useSubscriptfor display purposes. They can be used for calculation purposes, but there's some strange subtleties arising with their use that even somewhat experienced users can't predict. It is recommended to use things likeS[i,j]instead. In that case, your problem with be resolved automatically, and if you want, you can choose to display quantities likeS[i,j]as subscripted symbols later. – march Dec 07 '15 at 23:11Simplifyshould be considered a "calculation". I'll do theSimplifyon the unadulterated expressions and then change to subscripts. Thanks! – Zorawar Dec 07 '15 at 23:16Subscript[Subscript[Subscript[S,i],j],k]. Regardless, even with the parenthesis form, I think $((S_i)_j)^2$ would be better in order to make clear that the subscript operations are higher in the order of operations as is usual in mathematics. But, it's a fair point :) – Zorawar Dec 08 '15 at 01:12