MathGroup Archive 2002

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

Search the Archive

RE: Assigning to superscripted variables

  • To: mathgroup at smc.vnet.net
  • Subject: [mg34303] RE: [mg34282] Assigning to superscripted variables
  • From: "David Park" <djmp at earthlink.net>
  • Date: Tue, 14 May 2002 04:10:53 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Dave,

It is not totally clear what you are trying to do. I assume you are looking
for a tensor type index on a variable, i.e. you want a superscript to be
treated like a subscript is treated. But do you really want to throw away
the ability to have powers?

I am interested in what answers you will get. I would say that if you want
super indexed variables you have to define a special form for them and then
give an output formatting. I also alter the output formatting of Power. It
puts parentheses around the quantity that is being raised to a power.

An upper indexed variable will be represented and entered as super[x,i].

Format[super[x_, i_Integer]] := Superscript[x, i]

Unprotect[Power];
Format[ Power[A_, sup_]] := Superscript[SequenceForm["", A, ""], sup];
Protect[Power];

Then

super[a, 2]
% // FullForm
(superscript form)
super[a, 2]

a^2
% // FullForm
(power with parentheses)
Power[a, 2]

super[a, 2]^2
% // FullForm
(power of a superscript variable)
Power[super[a, 2], 2]

Now you can assign values to the indexed variable.

super[a, 2] := 5
super[a, 2]^2
25

David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



> From: Dave Snead [mailto:dsnead6 at charter.net]
To: mathgroup at smc.vnet.net
>
> 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
>



  • Prev by Date: Stephen Wolfram's A NEW KIND OF SCIENCE
  • Next by Date: RE: Assigning to superscripted variables
  • Previous by thread: Re: Assigning to superscripted variables
  • Next by thread: RE: Assigning to superscripted variables