Mathematica 9 is now available
Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
1999
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 1999

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

Search the Archive

Re: Curious weakness in Simplify with Assumptions

  • To: mathgroup at smc.vnet.net
  • Subject: [mg19033] Re: Curious weakness in Simplify with Assumptions
  • From: Adam Strzebonski <adams at wolfram.com>
  • Date: Tue, 3 Aug 1999 13:45:02 -0400
  • References: <E11AbU1-0004ZX-0C@finch-post-12.mail.demon.net>
  • Sender: owner-wri-mathgroup at wolfram.com

Andrzej Kozlowski wrote:
> 
> Today I noticed a weakness in Simplify with assumptions. I tried
> 
> In[1]:=
> Simplify[Sqrt[x] \[Element] Reals, x >= 0]
> Out[1]=
> Sqrt[x] \[Element] Reals
> 

The rule used to prove that a Power expression is real
is too weak, namely

a^b is real if

(i) b is an integer and a is real and (b>0 or a!=0)

or 
 
(ii) b is real and a>0.

I will add  

(iii) b>0 and a>=0.

Thanks for pointing this out.

> This leads to the following curious situation:
> 
> In[2]:=
> Simplify[Sqrt[a^2 + b^2] \[Element] Reals,
>   a \[Element] Reals && b \[Element] Reals]
> Out[2]=
>       2    2
> Sqrt[a  + b ] \[Element] Reals
> 
> even though:
> 
> In[3]:=
> Simplify[Sqrt[a^2 + b^2] \[Element] Reals, (a \[Element] Reals) && (b > 0)]
> Out[3]=
> True
> 
> In[4]:=
> Simplify[Sqrt[a^2 + b^2] \[Element] Reals, (a \[Element] Reals) && (b < 0)]
> Out[4]=
> True
> 

Here in both cases a^2+b^2>0 so rule (ii) can be used.

> and
> 
> In[5]:=
> Simplify[Sqrt[a^2 + b^2] \[Element] Reals, (a \[Element] Reals) && (b == 0)]
> Out[5]=
> True
> 

Here Sqrt[a^2+b^2] simplifies to Sqrt[a^2], and then to Abs[a],
which Mathematica knows is real.

> which covers all the possibilities. Surely this is something that ought to
> be fixed quite easily?
> 

The function arealq[a, assum] defined below gives True 
if it can prove that a is real and False otherwise. It
uses the rule (iii) in addition to rules known to
Simplify.

In[1]:= arealq[a_^b_, assum_] :=
   Experimental`ImpliesQ[assum,
   b>0 && a>=0 || Element[a^b, Reals]]

In[2]:= arealq[a_Plus, assum_] :=
   And@@(arealq[#, assum]&/@(List@@a))

In[3]:= arealq[a_Times, assum_] :=
   And@@(arealq[#, assum]&/@(List@@a))

In[4]:= arealq[other_, assum_] :=
   Experimental`ImpliesQ[assum, Element[other, Reals]]

In[5]:= Unprotect[Simplify];

In[6]:= Simplify[Element[a_, Reals], assum_, ___] :=
   True /; arealq[a, assum]

In[7]:= Protect[Simplify];

In[8]:= Simplify[Sqrt[x] \[Element] Reals, x >= 0]
Out[8]= True

In[9]:= Simplify[Sqrt[a^2 + b^2] \[Element] Reals,
  a \[Element] Reals && b \[Element] Reals]
Out[9]= True
 
In[10]:= Simplify[Sqrt[x] \[Element] Reals, x \[Element] Reals]
Out[10]= Sqrt[x] \[Element] Reals
 
One can use Simplify[e, assum]===True instead of
Experimental`ImpliesQ[assum, e] in the definition of
arealq. The difference is that Experimental`ImpliesQ
only tries to prove that e is True using assumptions
assum, and gives False if it can't, while Simplify will 
try to put e in a simplest form even if it cannot show 
that e is True.

In[2] and In[3] are added so that arealq can prove
also some simple consequences of rule (iii), like

In[11]:= Simplify[Element[Pi (E + 2 Sqrt[x]), Reals], x>=0]
Out[11]= True
 

Best Regards,

Adam Strzebonski
Wolfram Research


  • Prev by Date: Problem with <<DiscreteMath`KroneckerDelta`
  • Next by Date: Re: Discrete Convolution
  • Previous by thread: Curious weakness in Simplify with Assumptions
  • Next by thread: RE: Tutorial on NIntegrate needed