Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2006
*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 2006

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

Search the Archive

Re: ComplexityFunction affects set of transformations tried by Simplify

  • To: mathgroup at smc.vnet.net
  • Subject: [mg71570] Re: ComplexityFunction affects set of transformations tried by Simplify
  • From: dh <dh at metrohm.ch>
  • Date: Thu, 23 Nov 2006 05:41:42 -0500 (EST)
  • Organization: hispeed.ch
  • References: <200611202311.SAA18396@smc.vnet.net> <ejuqdp$htk$1@smc.vnet.net>

Hi Andrzej,
obviously it should read: expr1 = Sqrt[c + d/k](c k + d)^2 and not
expr1 = Sqrt[c + d/k]*(d + c*k)*2 and then the question makes sense.
Daniel

Andrzej Kozlowski wrote:
> On 21 Nov 2006, at 08:11, Schochet wrote:
> 
>> Oops! I originally sent this as a reply to an unrelated thread.
>> Please reply only to this new version.
>>
>> As part of a large computation, I wanted Mathematica to
>> simplify expressions of the form   Sqrt[c + d/k](c k + d)2,
>> where k is positive, to   (c k + d)^(5/2)/Sqrt[k]
>>
>> Note that Mathematica knows that the two expressions
>> are equivalent:
>>
>> In[1]:=expr1 = Sqrt[c + d/k](c k + d)2;
>> expr2 = (c k + d)^(5/2)/Sqrt[k];
>> Simplify[expr1 == expr2, k > 0]
>>
>> Out[1]=True
> 
> Rather unlikely, I would say. Consider that my Mathematica 5.1 gives:
> 
> expr1 = Sqrt[c + d/k]*(d + c*k)*2;
> expr2 = (d + c*k)^(5/2)/Sqrt[k];
> 
> 
> Simplify[expr1 == expr2, k > 0]
> 
> 
> (d + c*k - 2)*Sqrt[d + c*k] == 0
> 
> furthermore
> 
> expr1 /. {d -> 1, c -> 0, k -> 1}
> 
> 
> 2
> 
> 
> expr2 /. {d -> 1, c -> 0, k -> 1}
> 
> 
> 1
> 
> It kind of makes the rest of the message less interesting but...
> 
>> However Simplify with LeafCount as the ComplexityFunction
>> leaves expr1 unchanged, while Simplify with Depth as the
>> ComplexityFunction changes expr1 to expr2:
>>
>> In[3]:=Simplify[expr1, k > 0,
>> ComplexityFunction -> LeafCount] // InputForm
>>
>> Out[3]//InputForm=Sqrt[c + d/k]*(d + c*k)2
>>
>> In[4]:=Simplify[expr1, k > 0,
>> ComplexityFunction -> Depth] // InputForm
>>
>> Out[4]//InputForm=(d + c*k)^(5/2)/Sqrt[k]
>>
>> What explains this difference in behavior? Changing the order
>> of calculations 3 and 4 has no effect.  Since  calculation 2
>> shows that the form expr2 would be preferred if it were tried,
>> while calculation 4 shows that the form expr2 is tried when
>> the ComplexityFunction is Depth, it seems that the choice of
>> ComplexityFunction affects the set of transformations tried
>> by Simplify.
> 
> Here I get:
> 
> 
> In[4]:=
> Simplify[expr1, k > 0, ComplexityFunction -> LeafCount]
> 
> Out[4]=
> (2*(d + c*k)^(3/2))/Sqrt[k]
> 
> In[6]:=
> Simplify[expr1, k > 0, ComplexityFunction -> Depth]
> 
> Out[6]=
> (2*(d + c*k)^(3/2))/Sqrt[k]
> 
> 
> So, the way I see it there are two possibilities. One is, that there  
> was something funny with the state of your Mathematica when you got  
> those results. If not, then I am  pleased that I have not upgraded  
> from version 5.1 to 5.2 ;-)
> 
> Andrzej Kozlowski
> Tokyo, Japan
> 
> 
> 
> 


  • Prev by Date: StringReplace with empty list (Mathematica wish list)
  • Next by Date: Re: Method option to Solve
  • Previous by thread: Re: ComplexityFunction affects set of transformations tried by Simplify
  • Next by thread: General--Trigonometric functions manipulations in Mathematica