I try to make designation
a = {Subscript[a,1], Subscript[a,2], Subscript[a,3]}
but receive mistake
$RecursionLimit::reclim: Recursion depth of 1024 exceeded.
What`s the problem?
Answer
The reason is, that while assigning, the a in Subscript[a,_] is replaced by the whole list of subscripts, and so on and so on, until the recursion limit is reached: Subscripts are no symbols by themselves.
To avoid this, you can either use another variable to assign to (b e.g.), or define the subscripts as proper symbols:
Needs["Notation`"]
makesymbol[obj_]:=With[{},
If[NameQ@ToString@Unevaluated@obj,Remove@obj]; (* remove possibly existing symbol first *)
Symbolize@ParsedBoxWrapper@ToBoxes@obj;] (* then create the new symbol *)
With this function, you can create a symbol like so:
makesymbol[Subscript[a,1]]
Mathematica will now treat it the same as any other (simpler) symbol.
For your case:
Be sure to put the formatted variables into the list here, not the Subscript-form:
makesymbol /@ {Subscript[a, 1], Subscript[a, 2], Subscript[a, 3]}
and then your assignment will work without problems.
Comments
Post a Comment