One idea is to automatically change Subscript[a, n] into Subscript[RawBoxes["a"], n] to avoid recursion errors. Both a and RawBoxes["a"] look the same, so you will only notice that they are different by looking at the InputForm/FullForm of an expression (this is an idea I mentioned previously in (137993)). A couple possibilities to do this are:
If you always enter subscripts using control + _, then you can use a MakeExpression rule:
MakeExpression[SubscriptBox["a", n_], StandardForm] := With[
{v = HoldComplete[RawBoxes["a"]], sub = MakeExpression[n, StandardForm]},
Thread[Unevaluated @ Subscript[v, sub], HoldComplete]
]
Or, you can add DownValues to Subscript:
Subscript /: Subscript[a, n_] := Subscript[RawBoxes@"a", n]
Subscript /: Set[Subscript[a, n_], rhs_] := Subscript[RawBoxes@"a", n] = rhs
Depending on your workflow, you may need to do both. Note, however, that overriding built-in symbols in this way can lead to trouble. This is why I've written the above code to only work for a, and not for any symbol.
At any rate, now you can do things like:
Solve[a + Subscript[a, 1] == 0, a]
D[a + Subscript[a, 1], a]
{{a -> -Subscript[a, 1]}}
1
as well as your original example:
a = {Subscript[a, 1], Subscript[a, 2], Subscript[a, 3]}
a // InputForm
{Subscript[a, 1], Subscript[a, 2], Subscript[a, 3]}
{Subscript[RawBoxes["a"], 1], Subscript[RawBoxes["a"], 2], Subscript[RawBoxes["a"], 3]}
Notice, no recursion errors.
Subscriptbut about the fact that you set a value ofawhich depends ofa, like:a = {a, 1}. Try to rename it:vector = {Subscript[b, 1], 1}– Kuba Mar 09 '17 at 13:14aisn't the same asSubscript[a,x]so why does Mathematica sees it this way-and hence, arriving at a conflict? – Physkid Mar 09 '17 at 13:16ahere and there, inSubscriptand on the right hand side of=. By the way,Subscriptis not special so any head will give the same problem, like in the example from the first comment. – Kuba Mar 09 '17 at 13:17aas a vector is being recursively substituted forain the expressionSubscript[a, x]. This would result in an infinite loop if it were not for the internal limit$RecursionLimit. Note also, that ifxhas a value, it would be substituted as well; similarly foryandz. Look up the Notation package in the docs or on this site, if you wish to use such notation in Mathematica. – Michael E2 Mar 09 '17 at 14:26