ComplexityFunction affects set of transformations tried by Simplify

*To*: mathgroup at smc.vnet.net*Subject*: [mg71492] ComplexityFunction affects set of transformations tried by Simplify*From*: "Schochet" <schochet at netvision.net.il>*Date*: Mon, 20 Nov 2006 18:11:55 -0500 (EST)

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 Furthermore, both the LeafCount and the Depth of expr2 are smaller: In[2]:={LeafCount[#], Depth[#]} & /@ {expr1, expr2} Out[2]={{19, 6}, {15, 5}} 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. For the record, I am using $Version 5.2 for Linux (June 20, 2005) Steve

**Follow-Ups**:**Re: ComplexityFunction affects set of transformations tried by Simplify***From:*Andrzej Kozlowski <akoz@mimuw.edu.pl>