I have a question about subscript policy. For some reason I have some variables called Subscript[q, 1], Subscript[q, 2], Subscript[q, 3] and Subscript[q, 4]. I know that I could have called them in other ways, but even (not only) for them to be more human readable I decided to call them this way. Now I have the expression

Series[Sin[q Subscript[q, 3]], {q, 0, 0}]

which is not evaluated as I want. To cricumvent this I wrote

Series[Sin[q q3], {q, 0, 0}]/.{q3->Subscript[q, 3]}

which works, but is not elegant. Is that an elegant way to make Mathematica understand that in this case the subscript is just the name of a variable?

  • 3
    $\begingroup$ No, I don't think so. Some use the "Notation`" package. Or perhaps Subscript["q", 3]? One particular problem is that the q is the same variable in both factors of q Subscript[q, 3]; the other is that Subscript[q, 3] is treated as a function of q, which you cannot avoid. Since you're willing to type q3, you could try something like Format[q3] = Subscript["q", 3], especially if output formatting is the goal; see also MakeBoxes[]. $\endgroup$
    – Michael E2
    Sep 20, 2016 at 10:41
  • $\begingroup$ Both versions of your command result in the same result for me (O[q]^1). Do you have an example where the results differ and you can say which you want? $\endgroup$
    – Chris K
    Sep 20, 2016 at 13:25
  • $\begingroup$ Concerning subscripts, I added the same issue. I know use the "Notation" package. It runs event it is quite long to define all my variables like this. $\endgroup$
    – Bendesarts
    Sep 20, 2016 at 14:45


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.