Re: PowerExpand
- To: mathgroup at smc.vnet.net
- Subject: [mg63550] Re: [mg63537] PowerExpand
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Thu, 5 Jan 2006 03:12:18 -0500 (EST)
- References: <200601040817.DAA26079@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 4 Jan 2006, at 17:17, Blimbaum, Jerry CIV NSWC PC wrote: > > Just want to make a comment.....Normally PowerExpand is looked upon > as a > culprit because for the general case it leads to wrong > results......However, I had an interesting case where I tried > > Siimplify[expr, m>0] ....expr was of 2 basic forms (although really > more complicated then this, but this shows the basic idea) > > .....Sqrt[-m^2 (a^2+b^2)] and Sqrt[m^2 (a^2+b^2)] > > With Simplify Mathematica cranked and cranked and cranked with no > output.....So , in frustration, I tried PowerExpand and a second > later > it performed the same operation with surprising ease and the result > was > exactly what i was trying to get... > > If I try the basic expressions , then Simplify took m out of the > Square > Root sign for the Sqrt[m^2 (a^2+b^2)] but not for Sqrt[-m^2 > (a^2+b^2)] > > > jerry blimbaum > > This is simply because according to the default ComplexityFunction (which is roughly but no exactly the same as LeafCount) the expression you expect to get is not simpler than the one you are simplifying: LeafCount[Sqrt[(-m^2)*(a^2 + b^2)]] 16 LeafCount[Sqrt[-a^2 - b^2]*m] 17 This means that you what you need is to use a different ComplexityFunction. This issue has come up lots of times in the past and on several such occasions I posted the following variant of Simplify, which should produce the simplest form according to the "typesetting" criterion of simplicity, which is probably the closest to what most human beings use instinctively: VisibleSimplify[expr_, opts___] := Simplify[ expr, opts, ComplexityFunction -> \ (StringLength[ToString[TraditionalForm[#]]] &)] VisibleSimplify[Sqrt[m^2*(a^2 + b^2)], m > 0] Sqrt[a^2 + b^2]*m VisibleSimplify[Sqrt[(-m^2)*(a^2 + b^2)], m > 0] Sqrt[-a^2 - b^2]*m Of course VisibleSimplify is very much less efficient than the usual Simplify with the default ComplexityFunction! Andrzej Kozlowski
- References:
- PowerExpand
- From: "Blimbaum, Jerry CIV NSWC PC" <jerry.blimbaum@navy.mil>
- PowerExpand