RE: Controlling evaluation in Symbolize
- To: mathgroup at smc.vnet.net
- Subject: [mg30371] RE: [mg30352] Controlling evaluation in Symbolize
- From: "David Park" <djmp at earthlink.net>
- Date: Sun, 12 Aug 2001 02:30:00 -0400 (EDT)
- Sender: owner-wri-mathgroup at wolfram.com
Richard, Someday, I swear, I am really really going to learn how to use the Notation package. It is probably quite useful once one learns the tricks. Unfortunately, for me it takes a day and a half to learn each of its tricks. For your problem, what is really needed is a way to Map the Symbolize statement onto a list of variables. But that does not seem to be possible. However, I was able to devise the following method using the NotationBoxTag form of the Symbolize statement. I use r,s,t for the variable names to simplify the email text. Still it is not possible to show all the input and output forms because notations depends upon the specific 2-dimensional structures. Needs["Utilities`Notation`"] Needs["Calculus`VectorAnalysis`"] SetCoordinates[Spherical[r, s, t]]; The following will symbolize your B variables for a given set of coordinates. Hold[Symbolize[ NotationBoxTag [ SubscriptBox["B", subvar ] ]]] % /. Partition[Thread[subvar -> ToString /@ Coordinates[]], 1] % // ReleaseHold; We can see that they have been successfully symbolized by looking at the list of subscripted symbols in FullForm. (They have to be typed in with their 2-dimensional structure.) List[B\[UnderBracket]Subscript\[UnderBracket]r, B\[UnderBracket]Subscript\ \[UnderBracket]s, B\[UnderBracket]Subscript\[UnderBracket]t] The symbols can be removed this way. Hold[RemoveSymbolize[ NotationBoxTag [ SubscriptBox["B", subvar ] ]]] % /. Partition[Thread[subvar -> ToString /@ Coordinates[]], 1] % // ReleaseHold; Remove @@ List[B\[UnderBracket]Subscript\[UnderBracket]r, B\[UnderBracket]Subscript\[UnderBracket]s, B\[UnderBracket]Subscript\[UnderBracket]t] If we look at the FullForm of the 2-dimensional expressions we now obtain List[Subscript[B, r], Subscript[B, s], Subscript[B, t]] That only took me three hours, a record for me with the Notation package. The documentation says that use of NotationBoxTag is for advanced users. But your application of Notation seems to be a common type of thing that one would wish to do. David Park djmp at earthlink.net http://home.earthlink.net/~djmp/ > From: Richard Gass [mailto:gass at physics.uc.edu] To: mathgroup at smc.vnet.net > > I need to create a number of symbols (things like SubscriptBox["B", > "r"]). I want this to behave as a single object so I need to > Symbolize it. My symbols will all be subscripts but my question is > more general. Here is a simple example: First I load some packages > and set the coordinate system > > << Calculus`VectorAnalysis` > << Utilities`Notation` > SetCoordinates[Spherical[r, \[Theta], \[Phi]]] > (* now from the palette I Symbolize B sub anything *) > > \!\(\* > RowBox[{"Symbolize", "[", > TagBox[\(B\_x_\), > NotationBoxTag, > TagStyle->"NotationTemplateStyle"], "]"}]\) > > (* Next I want to generate the needed symbols. *) > > > In[9]:= > \!\(Table[B\_\(\(Coordinates[]\)[\([i]\)]\), {i, 1, 3}]\) > > Out[9]= > \!\({B\_\(\(Coordinates[]\)[\([\)\(i\)\(]\)]\), > B\_\(\(Coordinates[]\)[\([\)\(i\)\(]\)]\), > B\_\(\(Coordinates[]\)[\([\)\(i\)\(]\)]\)}\) > > (* But Symbolize freezes the evaluation so that Coordinate[][[i]] > does not evaluate. What I want is > > In[4]:= > \!\(Table[B\_\(\(Coordinates[]\)[\([i]\)]\), {i, 1, 3}]\) > > Out[4]= > \!\({B\_r, B\_\[Theta], B\_\[Phi]}\) > > This code was of course, run before I symbolized B sub anything. What > I want to do is to force the evaluation of Coordinates[][[i]] so that > I generate B sub r, B sub theta and B sub phi as proper symbols. > Since I do not know in advance what coordinate system will be used, > just typing them in is not an option *) Any ideas? > -- > Richard Gass > Department of Physics > University of Cincinnati > Cincinnati, OH 45221 > phone- 513-556-0519 > E-Mail gass at physics.uc.edu >