MathGroup Archive 2002

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

Search the Archive

RE: Assigning to superscripted variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34291] RE: [mg34282] Assigning to superscripted variables
  • From: "Wolf, Hartmut" <Hartmut.Wolf at t-systems.com>
  • Date: Tue, 14 May 2002 04:10:00 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

> -----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: [mg34291] [mg34282] 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



  • Prev by Date: RE: Assigning to superscripted variables
  • Next by Date: Re: Limit with restrictions
  • Previous by thread: RE: Assigning to superscripted variables
  • Next by thread: Re: Assigning to superscripted variables