Re: Simplify
- To: mathgroup at smc.vnet.net
- Subject: [mg98683] Re: Simplify
- From: Szabolcs <szhorvat at gmail.com>
- Date: Thu, 16 Apr 2009 04:14:29 -0400 (EDT)
- References: <gs47pv$7tv$1@smc.vnet.net>
On Apr 15, 12:01 pm, dh <d... at metrohm.com> wrote: > Hi, > > can somebody explain, why > > Simplify[x^2/y^2,ComplexityFunction->LeafCount] > > does not simplify to (x/y)^2, although the LeafCount is: > > LeafCount[Hold[x^2/y^2]] gives 10 > > and > > LeafCount[Hold[(x/y)^2]] gives 8 > Hello Daniel, There are two reasons. First, try this: In[1]:= FullForm[Hold[x^2/y^2]] Out[1]//FullForm= Hold[Times[Power[x,2],Power[Power[y,2],-1]]] In[2]:= FullForm[x^2/y^2] Out[2]//FullForm= Times[Power[x,2],Power[y,-2]] Second, (x/y)^2 autoevaluates to x^2/y^2, so no function can return (x/ y)^2 without some kind of Hold-wrapper. The LeafCounts of the different forms are In[9]:= LeafCount[Unevaluated[x^2/y^2]] Out[9]= 9 In[10]:= LeafCount[x^2/y^2] Out[10]= 7 In[11]:= LeafCount[Unevaluated[(x/y)^2]] Out[11]= 7