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?
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.
My favorite approach when it's unavoidable to use such formatting is this simple trick:
a = {Subscript["a", 1], Subscript["a", 2], Subscript["a", 3]}
(* ==> {Subscript["a", 1], Subscript["a", 2], Subscript["a", 3]} *)
Just make the subscripted names into strings. You can then do things like a[[1]]
or even Subscript["a", 1] = 10
without getting in trouble. The quotation marks also remind you that you're dealing with something more subtle: The value in the last assignment is stored in DownValues[Subscript]
. This is the big difference in using Subscript
versus regular symbol names, and one should never forget it.
As usual, you can find most of this by searching the following giant Q&A: What are the most common pitfalls awaiting new users?.
s a little strange situation: it
s possible to Superscript (not the Power) but impossible to Subscript (not index). It`s not good. In any case. Many thanks for all. Where to find wish list for mma? $\endgroup$