Re: ComplexityFunction affects set of transformations tried by Simplify

• To: mathgroup at smc.vnet.net
• Subject: [mg71509] Re: [mg71492] ComplexityFunction affects set of transformations tried by Simplify
• From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
• Date: Tue, 21 Nov 2006 07:05:06 -0500 (EST)
• References: <200611202311.SAA18396@smc.vnet.net>

```On 21 Nov 2006, at 08:11, Schochet wrote:

> Oops! I originally sent this as a reply to an unrelated thread.
>
> 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: Re: Send graphics to file AND/OR to notebook with one DisplayFunction
• Next by Date: Re: Numerical Integration
• Previous by thread: ComplexityFunction affects set of transformations tried by Simplify
• Next by thread: Re: Re: ComplexityFunction affects set of transformations tried by Simplify