MathGroup Archive 2007

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

Search the Archive

Re: Re: Strange behaviour of Simplify


On 18 Jul 2007, at 07:56, Andreas Maier wrote:

> On Jul 16, 8:10 am, Andrzej Kozlowski <a... at mimuw.edu.pl> wrote:
>> On 15 Jul 2007, at 14:14, Andreas Maier wrote:
>>
>>
>>
>>> Hi,
>>
>>> i'm trying to simplify the following expression
>>
>>> In:= gamma=c Sqrt[g00])/Sqrt[c^2 g00 + g11 v^2]
>>> In:=LeafCount[gamma]
>>> Out:=52
>>
>>> using Simplify
>>
>>> In:= gamma2=Simplify[gamma, {Sqrt[g00] > 0, c > 0 }]
>>
>>> Out:=c/Sqrt[c^2 + (g11 v^2)/g00]
>>> In:=LeafCount[gamma2]
>>> Out:=44
>>
>>> Why is Mathematica (I'm using V6.0) able to cancel Sqrt[g00], but is
>>> not
>>> able to cancel c? I also tried ComplexityFunction->LeafCount, which
>>> should work, because
>>
>>> In:=gamma3=1/Sqrt[1 + (g11 v^2)/(c^2 g00)]
>>> In:=LeafCount[gamma3]
>>> Out:=43
>>
>>> the LeafCount of gamma3 is smaller than gamma2, but it doesn' work.
>>> Can anybody tell me, how i can transform gamma to gamma3 in
>>> Mathematica?
>>
>>> Andreas Maier
>>
>> There is nothing strange about this behaviour. Simplify only uses
>> certain specified transformation functions and applies certain
>> sequences of them (such that the complexity does not increase at any
>> step) but there is no such sequence of functions that would do what
>> you want, because any such sequence would have to temporarily inrease
>> the complexity of the expression. Rather than spend time and energy
>> on trying to find a suitable mix of TransformationFunctions and a
>> ComplexityFunction that would produce the result you want, it is much
>> simpler to use replacement rules or a combination of replacement
>> rules and Simplify, like this:
>>
>> Simplify[gamma /. c -> Sqrt[t], {Sqrt[g00] > 0, t > 0}] /. t -> c^2
>>
>> 1/Sqrt[(g11*v^2)/(c^2*g00) + 1]
>>
>> Andrzej Kozlowski
>
> Actually i figured that out by myself just before i read your message.
> But thank you anyway.
> Still i think this solution is not a very elegant one, since it
> involves a lot of guess work
> (Although in this case it was suggestive to try to substitute with a
> Sqrt[], but in general this might not be the case).
> Is there no possibility in Mathematica to manually move out certain
> factors from the enumerator and
> denominator and then let Simplify cancel these factors? I understand
> that Simplify cannot do transformations
> that temporarily generate a higher LeafCount, but it would be nice, if
> i could generate these expressions manually
> to give a new starting point for Simplify, so it can find expressions
> with an even lower LeafCount.
>
> Andreas Maier
>
>
>

As I have argued many times here, the purpose of Simplify is not to  
transform an expression into some form that is already known to the  
user. The right tool for this sort of thing are pattern matching and  
transformation rules. You can sometimes makes things a little simpler  
(at least as far as the amnount of typing is concerned) by a  
judicious use of Simplify but as you correctly note this involves  
guess work, since it is hard to tell exactly what output Simplify  
will return (because it is intended for quite a different purpose).  
So, in my opinion, the best way to do this sort of thing is as you  
would do it "by hand", and in this case I would use:

Numerator[gamma]/(c*Sqrt[g00])/
    Sqrt[Apart[Denominator[gamma][[1]]/(c^2*g00)]]

1/Sqrt[(g11*v^2)/(c^2*g00) + 1]

You can always use Simplify to verify that what you got is equal to  
gamma:

  Simplify[% == gamma, { c > 0, Sqrt[g00] > 0}]
True

Andrzej Kozlowski


  • Prev by Date: Re: annoying documentation in 6 (rant)
  • Next by Date: A WorkLife FrameWork: Mathematica 6 compatible version released on May 1st
  • Previous by thread: Re: Strange behaviour of Simplify
  • Next by thread: Re: Strange behaviour of Simplify