MathGroup Archive 2001

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

Search the Archive

Re: What is happening here? (TagSet)

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27897] Re: What is happening here? (TagSet)
  • From: "Allan Hayes" <hay at haystack.demon.co.uk>
  • Date: Fri, 23 Mar 2001 04:31:17 -0500 (EST)
  • References: <99chu9$8eq@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

John

For an unprotected symbol  a  entering

TagSet[a, ls, rs]

stores the rule for  ls = rs under the tag a, (provided that a is the
leftmost symbol of eitherthe head of ls or an element of ls )

We can use ?a to see what has been stored.
We can't tag by symbol any deeper in ls.

A typical use is  (using the short hand, a/:)

a/:Sin[a]=5;

Or, of necessity since we can't tag with 3,

b/:3[b]= 6;

Please look up UpValues with regard to the  ^.

With regard to

Clear[u,v,x,y,z];
Clear[f,F,X,Y,U,V,Z];
TagSet[x,Im[x],0];
TagSet[y,Im[y],0];
TagSet[u,Im[u[x,y]],0];
TagSet[v,Im[v[x,y]],0];
TagSet[x,Re[x],x];
TagSet[y,Re[y],y];
TagSet[u,Re[u[x,y]],u[x,y]];
TagSet[v,Re[v[x,y]],v[x,y]];



This is what has been accomplished is that if  zz is one of  x ,y,
u[x,y],v[x,y] then we have stored  the rules for Im[zz]=0 and Re[zz]= zz:
two ways of saying the  zz is real - later code may need both statements.


--
Allan
---------------------
Allan Hayes
Mathematica Training and Consulting
Leicester UK
www.haystack.demon.co.uk
hay at haystack.demon.co.uk
Voice: +44 (0)116 271 4198
Fax: +44 (0)870 164 0565

"John Todd" <johntodd at fake.com> wrote in message
news:99chu9$8eq at smc.vnet.net...
> Hello,
> I've been working my way through a notebook I found on the
> Internet, and the author states the following before executing some
> commands which I don't understand:
>
> file://begin copied text
> There are two methods for defining a complex function in Mathematica.
> Before we start, make x, y, u and v real variables.
>
> Clear[u, v, x, y, z];
> Clear[f, F, X, Y, U, V, Z];
> TagSet[x, Im[x], 0];
> TagSet[y, Im[y], 0];
> TagSet[u, Im[u[x, y]], 0];
> TagSet[v, Im[v[x, y]], 0];
> TagSet[x, Re[x], x];
> TagSet[y, Re[y], y];
> TagSet[u, Re[u[x, y]], u[x, y]];
> TagSet[v, Re[v[x, y]], v[x, y]];
> file://end copied text
>
> I of course, understand the clear statements, but I can't figure out
> what he's actually accomplishing.  I inserted statements akin to ?x,
> ?y, etc.  inbetween each instruction to see if anything was changing
> and couldn't glean any information from that, then I wrapped a few of
> the statements within a FullForm[] function call, which gave me
> something similar to this:
> file://FullForm =
> 0
> which didn't help me at all.  I've looked at the documentation, the
> Wolfram Book v.4 and searched the web, all to no avail.  I can't seem
> to find what TagSet is doing.  I read through the section on
> transformations and definitions as well, but there's nothing specific
> that says TagSet[x1, x2,...xi] then explains how the arguments work
> together.
>
> Thanks for any and all illumination,
>
> JT
>




  • Prev by Date: Re: What is happening here? (TagSet)
  • Next by Date: Re: Calling a remote kernel from an external program.
  • Previous by thread: Re: What is happening here? (TagSet)
  • Next by thread: Re: What is happening here? (TagSet)