MathGroup Archive 1999

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Subscripts, Doh!!!

  • To: mathgroup at
  • Subject: [mg19202] Re: Subscripts, Doh!!!
  • From: Jason Harris <j.harris at>
  • Date: Tue, 10 Aug 1999 02:52:55 -0400
  • References: <7o5ier$> <7oba5o$> <"199908060358.XAA08108">
  • Sender: owner-wri-mathgroup at

>(Colin Rose)  Wrote:
>David Bailey <db at> wrote:
>> I have always found the way Mathematica handles subscripts rather neat.
>Me too. Mostly. And it's much better under v4 than v3.

[Snipped : Observations about subscripts and improvements in version 4. ]
(I missed these in my earlier post... mainly since these are not the 
main reasons I personally use Symbolizations and Notations. 
Admittedly though, it appears that the handling by "solve" type 
functions looks like it has been improved.)

Just using subscripted symbols has its problems though...

For instance  \!\(\(?m\_1\)\), that is ? m sub 1 will yield an error. 
As will something like \!\(Clear[m\_1]\), that is Clear[ m sub 1]. 

>3.  Symbolize ?
>Symbolize looks like a pretty amazing piece of work:
>trying to retrofit a new framework on an existing structure.
>That being said, I must say that I don't like Symbolize.
>I shall offer 3 reasons:

Symbolize is not a universal panacea. Its main use where it is 
indispensable is when you want rules and definitions involving 
subscripted symbols. However, one should still  be weary of when to 
use it and when not to use it.

>(i)  << Utilities`Notation`

[snipped parts (illustrating the creation of subscripted expressions 
and symbols that have the same output form)]

>We now have two sets of "identical" notation in use.
>In the one set, m_2 is a Symbol;  in the other set, m_2 is a Subscript
>(not a Symbol). They both look the same on screen. Tres confusing !

This is really just a case of your point number (iii) which I address below.

>(ii) More generally, what you see is NOT what you get
>     The Symbolize package uses a palette based entry method.
>     The reason it uses a palette entry system is because underneath,
>     it is adding a much more complicated tag box structure. So while
>     it looks like:
>        Symbolize[x_2]
>    in fact the full Input story is:
>        Symbolize[NotationBoxTag[\(x\_2\)]]
>    This makes reproducing results in textbooks very difficult, or cumbersome.

In v4 you can now see the tag boxes behind the symbolizations and 
notations. It is sooooo much easier to visually identify the 
structures being modified. Also using Esc-symbolize-Esc and 
Esc-notation-Esc makes entering these structures much easier.

(Actually there is a slight glitch in unix & linux versions which 
causes these styles not to be shown properly... To do with the 
handling of SelectedNotebook[] being different in Windows and 
Macintosh systems to that of Linux & Unixes.  There is an update for 
linux systems at .)

>(iii)  Ideally, one would be able to
>        Symbolize[ Subscript[x, _Integer] ]
>       and then be able to work with
>              Table[x_i, {i, 1, 4}]
>       where each of x_1, x_2, x_3 etc are treated as symbols.
>       But none of this works.

Although it is not in the introduction of the documentation, methods 
to accomplish this are actually given in the documentation. (Under 
complex patterns...)

Here is some code to do what you request. (It looks much better on 
screen than below. It takes only 3 lines on screen.)

     RowBox[{"Symbolize", "[",
         TagStyle->"NotationTemplateStyle"], "]"}],
     "\n", \(m\_\(i_?IntegerQ\) := ToExpression\ @\ MakeBoxes[\ m\_i]\),
     "\n", \(unparsedNumericQ\ \ @\ \ boxes___\  := \ \
\[IndentingNewLine]ReleaseHold\ @\ \(Hold[
             NumericQ]\ @\ \(Hold[Unevaluated]\ @\
             ToExpression[boxes, StandardForm, Hold]\)\)\)}]\)

Or in plain text

         TagBox[RowBox[List["i_", "?", "unparsedNumericQ"]],
           Rule[TagStyle, "NotationPatternWrapperStyle"]]]]]

Subscript[m, i_?IntegerQ] := ToExpression @ MakeBoxes @ Subscript[m, i]

unparsedNumericQ  @  boxes___ :=
   ReleaseHold @
     Hold[NumericQ] @
       Hold[Unevaluated] @ ToExpression[boxes, StandardForm, Hold]

The function UnparsedNumericQ carefully tries to determine if a 
string is a number without evaluating it.

Here is an illustrative example. (Assuming the Notation package has 
been loaded and the above code entered.)

\!\(Table[m\_i, {i, 1, 3}] === {m\_1, m\_2, m\_3}\)

Yet m subscripted by things other than integers remain 
"expressionized" rather than "symbolized".


While m subscripted by integers is symbolized.


Of course, this is all possible programmatically so one can easily 
define a function to automate this. In summary and to reiterate, just 
like any programming structure in Mathematica, Symbolize will not be 
applicable in every situation, but when applicable it can lead to 
elegant solutions.


    Jason Harris

  • Prev by Date: Re: Any Hazards When Installing V3 and V4 in Parallel?
  • Next by Date: Re: Automatic grouping of animation cells
  • Previous by thread: Re: Subscripts, Doh!!!
  • Next by thread: Re: Subscripts, Doh!!!