Re: confused about asserting variable is element of Reals
- To: mathgroup at smc.vnet.net
- Subject: [mg103126] Re: [mg103084] confused about asserting variable is element of Reals
- From: Leonid Shifrin <lshifr at gmail.com>
- Date: Tue, 8 Sep 2009 06:01:32 -0400 (EDT)
- References: <200909070636.CAA04019@smc.vnet.net>
Dushan, you got confused due to your probably procedural programming background. 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 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 information that <a> should be considered real (in that particular computation): In[1] = ClearAll[a]; Simplify[Im[a], Assumptions -> Element[a, Reals]] Out[1] = 0 Regards, Leonid On Mon, Sep 7, 2009 at 10:36 AM, dushan <dushanm at spinn.net> wrote: > I'm still learning Mathematica (using 7.0.1) and don't understand > Mathematica's response. After finally finding out how to assert that a > variable is real, I tried to verify this by asking Mathematica to show me > that > it knew the imaginary part of the variable is zero. But I couldn't > find a way to do that.. Here're my instructions: > > In[1]:= a (ESC)el(ESC) Reals > Out[1]:= a (the element-of symbol) Reals > > In[2]:= ##Im[a] > Out[2]:= Im[a] > > where '##' is any of {null, Refine[, Simplify[, FullSimplify[}. I > also tried some other combinations, such as 'a^2 - Re[a]^2', but these > didn't help either. > > What am I doing wrong? How do I verify such things? > > Thanks. > > - Dushan Mitrovich > >
- References:
- confused about asserting variable is element of Reals
- From: dushan <dushanm@spinn.net>
- confused about asserting variable is element of Reals