Re: Assigning to superscripted variables
- To: mathgroup at smc.vnet.net
- Subject: [mg34323] Re: Assigning to superscripted variables
- From: "Dave Snead" <dsnead6 at charter.net>
- Date: Wed, 15 May 2002 03:35:10 -0400 (EDT)
- References: <abqh3r$9pf$1@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
Hi all, Thanks for the suggestions. I'm trying to keep the look and feel of a contravariant vector (or tensor), so I prefer not to throw parentheses around the superscript. Using a <Crtl>^ i = 5 works fine as long as I avoid assigning to "a" directly and keep the Protected attribute off of Power. And I've yet to encounter anything "dangerous" about unprotecting Power. The use of Power with expressions other than "a^i" works exactly as before. Since my initial posting I've discovered my problem was due to Simplify-- it's first use in a new session restores the Protected attribute of Power. This looks like a bug in Mathematica, since Simplify should not be altering the attributes of Power (and it's inconsistent about it too!). So if I just use Simplify before my use of Unprotect[Power] my problems disappear. The following is a new session showing the attribute altering behavior of Simplify: In[1]:= Attributes[Power] Out[1]= {Listable,NumericFunction,OneIdentity,Protected} In[2]:= Unprotect[Power]; In[3]:= Attributes[Power] Out[3]= {Listable,NumericFunction,OneIdentity} In[4]:= Simplify[0]; In[5]:= Attributes[Power] Out[5]= {Listable,NumericFunction,OneIdentity,Protected} In[6]:= Unprotect[Power]; In[7]:= Attributes[Power] Out[7]= {Listable,NumericFunction,OneIdentity} In[8]:= Simplify[0]; In[9]:= Attributes[Power] Out[9]= {Listable,NumericFunction,OneIdentity} Thanks, -- Dave Snead P.S. In[1]:=<< "Utilities`Notation`" In[2]:=Symbolize[a <Crtl>^ i] In[3]:=a <Crtl>^ i = 5 seems to work too, although Symbolize must be entered from the Notation palette and the expression in In[4] must be copied and pasted from In[2] since although it looks like a <Crtl>^ i it's really become a\[UnderBracket]Superscript\[UnderBracket]i "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com> wrote in message news:abqh3r$9pf$1 at smc.vnet.net... > > > -----Original Message----- > > From: Dave Snead [mailto:dsnead6 at charter.net] To: mathgroup at smc.vnet.net > > Sent: Monday, May 13, 2002 11:55 AM > > Subject: [mg34323] Assigning to superscripted variables > > > > > > Hi, > > > > I've been trying to assign values to superscripted variable, ex, > > a^i = 5 > > but I get a message that Tag Power is protected. > > I can > > Unprotect[Power] > > first and then it works fine. > > However after a few more expressions, Power somehow gets reprotected! > > Does anyone know what causes this? > > How can I keep Power unprotected for the remainder of the session? > > > > Thanks in advance, > > Dave Snead > > > > > > > Dave, > > better use the Notation package (see Help > Add-ons > Notation Package): > > In[1]:= << Utilities`Notation` > > In[2]:= \!\(a\^5 = 25\) > >From In[2]:= > \!\(Set::"write" \(\(:\)\(\ \)\) > "Tag \!\(Power\) in \!\(a\^5\) is Protected."\) > Out[2]= 25 > > so just entering a^5 still means Power[a,5], but _first_ symbolizing a^5 > does it: > > In[4]:= > \!\(\* > RowBox[{"Symbolize", "[", > TagBox[\(a\^5\), > NotationBoxTag, > TagStyle->"NotationTemplateStyle"], "]"}]\) > > You enter this through clicking at Symbolize[#] at the Notation Palette, and > then expanding # to what you want. Then you may treat that as a symbol > > In[5]:= \!\(a\^5 = 25\) > Out[5]= 25 > > and you may do funny things > > In[6]:= \!\(\@\(a\^5\)\%5\) > Out[6]= \!\(5\^\(2/5\)\) > > The fifth root of our symbol a^5 now is 5^(2/5) (Power is still available). > > However, you can't use Symbolize within an expression; here I tried to do it > within an assignment. > > In[7]:= > \!\(\* > RowBox[{ > RowBox[{"Evaluate", "[", > RowBox[{"Symbolize", "[", > TagBox[\(b\^2\), > NotationBoxTag, > TagStyle->"NotationTemplateStyle"], "]"}], "]"}], "=", "3"}]\) > >From In[7]:= > Set::"wrsym": "Symbol \!\(Null\) is Protected." > Out[7]= 3 > > In[8]:= Names["Global`*"] > Out[12]= > {"a", "a\[UnderBracket]Superscript\[UnderBracket]5", \ > "b\[UnderBracket]Superscript\[UnderBracket]2", "CapitalRomanNumeral", \ > "$NotationDebug"} > > You see what Symbolize has done: even b^2 has been symbolized, but didn't > get its desired value after the error occurred. > > In[9]:= \!\(b\^2\) > Out[9]= \!\(b\^2\) > > so symbolize in a prior line. > > -- > Hartmut > >