Re: Subscript[x, y] and the Symbol x
- To: mathgroup at smc.vnet.net
- Subject: [mg33804] Re: Subscript[x, y] and the Symbol x
- From: Hartmut Wolf <hartmut.wolf at t-systems.com>
- Date: Tue, 16 Apr 2002 03:52:05 -0400 (EDT)
- Organization: T-Systems GEI
- References: <a93b61$pi2$1@debis.com>
- Sender: owner-wri-mathgroup at wolfram.com
Curt Fischer schrieb: > > Dear Mathgroup: > > The Subscript function in Mathematica has no built-in meaning. What > definition can I give this function to allow me to use Subscript[x,y] as > a "stand-alone" symbol that is completely distinct from the Symbol x or > the Symbol y? For example: > > In[1]:= > \!\(f[x_, y_] := x\_y\ + \ x + y\) > > In[2]:= > f[2,2]//FullForm > > Out[2]//FullForm= > Plus[4,Subscript[2,2]] > > This is exactly what I don't want. Instead I want > Plus[4,Subscript[x,y]]. Is there a way to do this? > > Thanks for your help. > -- > Curt Fischer > Tokyo Institute of Technology > Dept. of Bioengineering Curt, to treat subscripted expressions as symbols best use the function Symbolize from the notation package: In[5]:= << Utilities`Notation` assuming your function is something like In[9]:= f[s_Symbol, x_, y_] := s + x + y then first symbolize your subscripted expression by first entering Symbolize[\[Placeholder]] from -- and that is important! -- the Notation Palette. At placeholder enter x then ctrl+shift+_ then y then ctrl+space and evaluate. You get something like this In[12]:= \!\(\* RowBox[{"Symbolize", "[", TagBox[\(x\_y\), NotationBoxTag, TagStyle->"NotationTemplateStyle"], "]"}]\) What is important is the NotationBoxTag. If you just enter In[11]:= \!\(Symbolize[x\_y]\) things wouldn't work. After this prelude, you can use x\_y as a symbol wherever you like: In[13]:= \!\(f[x\_\(\(y\)\(\ \)\), 2, 3]\) Out[13]= \!\(5 + x\_y\) Of course there is no point in this function f, you may simply enter In[15]:= \!\(x\_y + 2 + 3\) Out[15]= \!\(5 + x\_y\) or, if you like In[16]:= \!\(x\_y = 2 + 3\) Out[16]= 5 In[17]:= \!\(x\_y\) Out[17]= 5 -- Hartmut Wolf