Effect of TagSet
- To: mathgroup at smc.vnet.net
- Subject: [mg8620] Effect of TagSet
- From: seanross at worldnet.att.net
- Date: Fri, 12 Sep 1997 04:10:35 -0400
- Sender: owner-wri-mathgroup at wolfram.com
> > The simplest way to deal with this is to declare
> >
> > p/:Im[p]=0
> >
> > Then, f[x, p] will give you an answer (if Arg[x^2]!=\[Pi]).
> >
> > -------
> > Raya Khanin
The construct
x/:f[args]=rhs
Is called TagSet and is associated with "Upvalues" which seem to be
transformation rules associated with symbols, sort of like a custom
"Head". I am having trouble understanding what real effect setting them
has on the way expressions are evaluated. Take, for example, the
Integral[Exp[- Pi r^2/w^2,{r,-Infinity,Infinity}].
Mathematica returns:
If[Re[w^2]>0, Sqrt[w^2]/2,
Integral[Exp[- Pi r^2/w^2,{r,-Infinity,Infinity}]],
indicating that it doesn't know what to do with the integral if w is
complex. It would be lovely to "declare" w to be real and the post
above makes it sort of sound like w/:Im[w]=0 would do just that.
However, the assignment of the "Upvalue" makes no difference in the
output returned by Integrate in this case, so I am left still wondering
of what practical use are these "Upvalues".
Can anyone show a simple example in which the assignment of an Upvalue
(or DownValue) changes the way a subsequent expression is evaluated?
Please note I don't care about the integral example, I only used it as a
case in point.