MathGroup Archive 2009

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

Search the Archive

Re: confused about asserting variable is element of

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103222] Re: confused about asserting variable is element of
  • From: Peter Breitfeld <phbrf at t-online.de>
  • Date: Fri, 11 Sep 2009 05:24:12 -0400 (EDT)
  • References: <h8anf6$hk2$1@smc.vnet.net>

If you want that the variable x to be treated (like) a real Variable,
you may give UpValue to it:

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

Then you will get:

In[1]:= Clear[u, v, y]; Re[u+I x]
Out[1]= Re[u]

In[2]:= Im[u I +x]
Out[2]= Re[u]


Dushan Mitrovich wrote:

> Many thanks to all who replied.  Bob Hanlon's several alternative usages
> were particularly informative.  The one I was most interested in, also
> suggested by Dan Litchblau:
>
>     $Assumptions = Element[a, Reals];
> or
>     $Assumptions = $Assumptions && Element[a, Reals];
>
>
> Leonid Shifrin notes that
>
>   In some hypothetical procedural language the statement Element[a, Reals]
>   would only make sense if it globally assigns <a> a property of being
>   real.
>
> In fact, this is precisely what I want: an instruction telling Mathematica
> that, within the scope of that particular Notebook and absent user instruc-
> tions to the contrary, it is to assume in all procedures that the specified
> variable is real.  In particular, I don't want to have to re-specify that
> property every time I perform an operation, as suggested below:
>
>   In Mathematica, everything is an expression, and most expressions don't
>   introduce side effects (global changes).  When you enter Element[a,
>   Reals], this by itself does nothing.  It does not, in particular, change
>   any global property of symbol <a>.  However, this expression can be used
>   in commands like Simplify, FullSimplify, etc., to give them the informa-
>   tion that <a> should be considered real (in that particular computation)
>
>
> I did initially refer to the UsingAssociations.html article, where I found
> this description,
>
>   x \[Element\ dom  or  Element[x,dom]       assert that x is an element
>                                                of the domain dom
>
> This seemed like a straightforward statement of what I wanted to do, so
> that's what I tried.  The problem is that I thought it was an instruction
> that applied globally to that Notebook.  Now I've learned better.
>
> Thanks for all the help and education.
>
> - Dushan
>
>

-- 
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de


  • Prev by Date: Re: docs for Style, etc. (Antialiasing)
  • Next by Date: Re: Stylesheets and templates?
  • Previous by thread: Re: Re: confused about asserting variable is
  • Next by thread: SendMail and Novell Groupwise