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: [mg27889] Re: [mg27866] What is happening here? (TagSet)
  • From: BobHanlon at aol.com
  • Date: Fri, 23 Mar 2001 04:31:09 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

Clear[x]

Mathematica does not assume that x is real

{Re[x], Im[x]}

{Re[x], Im[x]}

To define x as Real you can use TagSet

?TagSet

"f/: lhs = rhs assigns rhs to be the value of lhs, and \
associates the assignment with the symbol f."*
  Button[More\[Ellipsis], ButtonData :> "TagSet", Active -> True, 
   ButtonStyle -> "RefGuideLink"]

x /: Re[x] = x;
x /: Im[x] = 0;

?x

x
Im[x] ^= 0
Re[x] ^= x

{Re[x], Im[x]}

{x, 0}

TagSet[var, f[var], rhs];

is equivalent to 

var /: f[var] = rhs


Bob Hanlon

In a message dated 2001/3/22 5:06:09 AM, johntodd at fake.com writes:

>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:
>
>//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]];
>//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:
>//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,
>


  • Prev by Date: Re: Integral problem
  • Next by Date: Problem with Mathematica fonts in pdfLaTeX
  • Previous by thread: What is happening here? (TagSet)
  • Next by thread: Re: What is happening here? (TagSet)