Use Assuming
Assuming[{Element[a, Reals]},
#[Im[a]]] & /@ funcs
{0,0,0}
Use the Assumptions option
#[Im[a], Assumptions ->
Element[a, Reals]] & /@ funcs
{0,0,0}
Use the Assumptions option short form
#[Im[a], Element[a, Reals]] & /@ funcs
{0,0,0}
Or add your assumption to $Assumptions
$Assumptions = Element[a, Reals];
#[Im[a]] & /@ funcs
{0,0,0}
Bob Hanlon
---- dushan <dus...@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
you have to state that Mathematica should use your assumption
Assuming[a \[Element] Reals, Simplify[Im[a]]]
Maybe you should have a look at the help of the global variable
$Assumptions
Cheers
Patrick
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
> 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):
So, could one ever write Assumptions -> Element[I, Reals] in any of
those commands?
In[1]:= Simplify[Re[I + 1], Assumptions -> Element[I, Reals]]
During evaluation of In[1]:= Simplify::fas: Warning: One or more assumptions
evaluated to False. >>
Out[1]= 1
On Wed, Sep 9, 2009 at 12:42 PM, AES <sie...@stanford.edu> wrote:
> In article <h859vn$q48$1...@smc.vnet.net>,
> Leonid Shifrin <lsh...@gmail.com> wrote:
>
> > 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):
>
Of course one can. Look, I'll do it below.
In[13]:= Simplify[Re[I*x], Assumptions->Element[I, Reals]]
Simplify::fas: Warning: One or more assumptions evaluated to False.
Out[13]= 0
Some people refer to this as GIGO. I am partial to the phrase "You get
what you get".
Daniel Lichtblau
Wolfram Research
$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
Element[I, Reals]
False
Simplify[Re[I], Element[I, Reals]]
Simplify::fas: Warning: One or more assumptions evaluated to False. >>
0
Simplify[Im[I], Element[I, Reals]]
Simplify::fas: Warning: One or more assumptions evaluated to False. >>
1
Bob Hanlon
---- AES <sie...@stanford.edu> wrote:
=============
In article <h859vn$q48$1...@smc.vnet.net>,
Leonid Shifrin <lsh...@gmail.com> wrote:
> 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
Element[I,Reals] automatically evaluates to False.
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:
--
_________________________________________________________________
Peter Breitfeld, Bad Saulgau, Germany -- http://www.pBreitfeld.de