MathGroup Archive 2010

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

Search the Archive

Re: Why can't Mathematica tell when something is algebraically

  • To: mathgroup at smc.vnet.net
  • Subject: [mg108207] Re: Why can't Mathematica tell when something is algebraically
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Wed, 10 Mar 2010 06:28:52 -0500 (EST)
  • References: <hn2ltj$3kt$1@smc.vnet.net> <201003091119.GAA06777@smc.vnet.net> <AF2BE895-2E51-4F9C-9410-8CB5CB418899@mimuw.edu.pl> <0F45FC76-FF73-4401-B3E6-011F8C6AFCDA@mimuw.edu.pl> <201003100645.BAA03016@smc.vnet.net>

Yes, but why something like this could not just be added to Mathematica 
to make life much easier to slightly sclerotic users?

Unprotect[Assuming];
Assuming[cond_, PowerExpand[expr_]] /; flag :=
 Block[{flag}, PowerExpand[expr, Assumptions -> cond]]
flag = True;

Assuming[Element[r, Reals],
 PowerExpand[r^2*Sqrt[(r^3 + r + 2)/r] -
       Sqrt[r^3*(r^3 + r + 2)]]]

r^(3/2)*Sqrt[r^3 + r + 2]*
     E^(I*Pi*Floor[Arg[r]/(2*Pi) - Arg[r^3 + r + 2]/
                (2*Pi) + 1/2]) - r^(3/2)*Sqrt[r^3 + r + 2]*
     E^(I*Pi*Floor[-((3*Arg[r])/(2*Pi)) -
              Arg[r^3 + r + 2]/(2*Pi) + 1/2])

?

Andrzej Kozlowski



On 10 Mar 2010, at 07:45, Adam Strzebonski wrote:

> All that Assuming does is locally changing the value of $Assumptions.
>
> Assuming[assum, expr]
>
> is a shorthand for
>
> Block[{$Assumptions = $Assumptions && assum}, expr]
>
> All functions that take the Assumptions option, with the exception of
> PowerExpand, have the default option setting of
>
> Assuptions :> $Assumptions
>
> This means that they will automatically use the value of $Assumptions,
> whether it has been set with Assuming, or directly with
>
> $Assumptions = assum
>
> PowerExpand is an exception, its default option setting is
>
> In[1]:= Options[PowerExpand]
> Out[1]= {Assumptions -> Automatic}
>
> where Automatic means that PowerExpand is allowed to assume that
> all "simple" power and log expansion transformations are valid.
> This is the expected default behaviour of PowerExpand.
>
> In[2]:= PowerExpand[(a b)^c]
>
>          c  c
> Out[2]= a  b
>
> If Assumptions was set to $Assumptions, which by default evaluates
> to True, PowerExpand would add terms that make the expansion valid
> without any assumptions and the expected default behaviour would not
> be preserved.
>
> In[3]:= PowerExpand[(a b)^c, Assumptions :> $Assumptions]
>
>          c  c  (2 I) c Pi Floor[1/2 - Arg[a]/(2 Pi) - Arg[b]/(2 Pi)]
> Out[3]= a  b  E
>
> Best Regards,
>
> Adam Strzebonski
> Wolfram Research
>
> Andrzej Kozlowski wrote:
>> In fact, I was wrong, and I forgot of something I once new (or =
assumed that it had been "fixed"). Assuming has no effect on PowerExpand =
and the answer returned is completely misleading.  For example:
>>
>> Assuming[Im[r] != 0,
>> PowerExpand[r^2 Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3 (r^3 + r + 2)]]]
>> 0
>>
>> which is of course wrong.
>>
>> PowerExpand only works with Assumptions passed view the Assumptions =
-> ... method and then the answer is very complicated:
>>
>> PowerExpand[
>> r^2*Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3*(r^3 + r + 2)],
>>   Assumptions -> Element[r, Reals]]
>>
>> r^(3/2)*Sqrt[r^3 + r + 2]*
>>     E^(I*Pi*Floor[Arg[r]/(2*Pi) - Arg[r^3 + r + 2]/
>>                (2*Pi) + 1/2]) - r^(3/2)*Sqrt[r^3 + r + 2]*
>>     E^(I*Pi*Floor[-((3*Arg[r])/(2*Pi)) -
>>              Arg[r^3 + r + 2]/(2*Pi) + 1/2])
>>
>> But, what is rather strange, this works:
>>
>> PowerExpand[r^2 Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3 (r^3 + r + 2)],
>> Assumptions -> r <= 0]
>>
>> even though it does not work with Simplify and Reduce
>>
>> Reduce[r^2 Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3 (r^3 + r + 2)] == 0 =
&&
>>  r < 0, r]
>> Reduce::cpow: Reduce was unable to prove that a radical of an =
expression containing only real variables and parameters is real valued. =
If you are interested only in solutions for which all radicals contained =
in the input are real valued, use Reduce with domain argument Reals. >>
>>
>> The question is then, does PowerExpand really do that correctly? It =
would be reassuring if someone from WRI would confirm it. (Getting the =
right answer with PowerExpand itself is not very reassuring...).
>>
>> I remember a while ago there was already a discussion here concerning =
the fact that PowerExpand is probably the only function that admits =
Assumptions only in the form Assumptions ->  and not via Assuming. I =
though that was going to be changed but it remains as it used to be. If =
changing this behaviour is really impossible I think there ought to be =
some sort of warning message that appears when one attempts to use
>> Assuming[something,PowerExpand[expr]], for obvious reasons.
>>
>> Andrzej Kozlowski
>>
>>
>> On 9 Mar 2010, at 14:22, Andrzej Kozlowski wrote:
>>
>>> It seems better to use:
>>>
>>> Assuming[Element[r, Reals],
>>> PowerExpand[r^2 Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3 (r^3 + r + 2)]]]
>>>
>>> 0
>>>
>>> PowerExpand with Assumptions ought to be as reliable as Simplify =
(which does not work in this case), whereas if you use it without =
assumptions it can return answers that will be false for some values of =
the variables (it makes use of the maximal assumptions that permit the =
expansion). The fact that Simplify works here with the assumption r>=0 =
but not r<0 appears to be a bug.
>>>
>>> Andrzej Kozlowski
>>>
>>>
>>>
>>>
>>> On 9 Mar 2010, at 12:19, dh wrote:
>>>
>>>> Hi,
>>>> Sqrt is a multivalued function. Therefore, your expression is not=

>>>> necessarily zero. If you are sure that all your variables are real =
and
>>>> that you only want the main branch of Power, then you can use =
PowerExpand:
>>>> r^2 Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3 (r^3 + r + 2)] // PowerExpand
>>>> Daniel
>>>>
>>>> On 08.03.2010 12:09, mmdanziger wrote:
>>>>> This isn't the first time that I've encountered something like =
this in
>>>>> Mathematica but in my calculations I got a term like this:
>>>>>
>>>>> r^2 Sqrt[(r^3 + r + 2)/r] - Sqrt[r^3 (r^3 + r + 2)]
>>>>>
>>>>> Which is obviously identically zero.  For some reason Simplify or =
even
>>>>> FullSimplify can't figure this out.  Once you get dependent on
>>>>> Mathematica these things are pretty disturbing...you forget about =
your
>>>>> own knowledge because the program tells you that things are
>>>>> different.  Then you sit there like an idiot checking an algebraic
>>>>> identity that any beginning precalc student should be able to =
solve no
>>>>> problem.
>>>>>
>>>>> Is there any way to get Mathematica to "wake up" to these things?  =
It
>>>>> has such a powerful algebraic engine for most things, why can't it =
see
>>>>> something simple like the above?  Do you really have to manually
>>>>> override and tell the program when things should be zero?
>>>>>
>>>>> For the time being I'll just sift through and test things by hand =
but
>>>>> I can't believe that there isn't a better way.
>>>>>
>>>>> Best,
>>>>> md
>>>>>
>>>>
>>>> --
>>>>
>>>> Daniel Huber
>>>> Metrohm Ltd.
>>>> Oberdorfstr. 68
>>>> CH-9100 Herisau
>>>> Tel. +41 71 353 8585, Fax +41 71 353 8907
>>>> E-Mail:<mailto:dh at metrohm.com>
>>>> Internet:<http://www.metrohm.com>
>>>>
>>>>
>>
>
>



  • Prev by Date: Re: Square root of a square
  • Next by Date: Setting default zoom factor in notebooks
  • Previous by thread: Re: Re: Why can't Mathematica tell when something is algebraically
  • Next by thread: Re: Why can't Mathematica tell when something is algebraically zero?