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

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

Search the Archive

Re: Simplfying inside Sqrt

  • To: mathgroup at smc.vnet.net
  • Subject: [mg55115] Re: [mg55106] Simplfying inside Sqrt
  • From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
  • Date: Sun, 13 Mar 2005 04:57:34 -0500 (EST)
  • Sender: owner-wri-mathgroup at wolfram.com

On 12 Mar 2005, at 08:36, billkavanagh at gmail.com wrote:

> Hi
>
> I'm wondering how to tell mathematica that I want terms like
> Sqrt[x^2+x^4] to be x*Sqrt[1+x^2].   I have an expression with a few
> terms like this in it so manually inserting a
> PowerExpand[Sqrt[Expand[x^2+x^4]] is no good to me.
>
> I've tried a general PowerExpand and Simplify with a Im[x]==0 around
> the whole expression but with no luck.
>
> Does anybody know how to do this?
>
> Thanks,
> Bill
>
> --
> William R. Kavanagh
> http://www.physics.mun.ca/~wkavanag
>
>
>
Your problem is that by most commonly used measures of complexity you 
are trying to replace a simper expressions by a more complex one. For 
example, the expression you want has the same LeafCount as the one you 
get but a higher Depth. So you need a carefully designed complexity 
function, that will treat such factored forms as simpler than 
unfactored ones but will not, as a side effect, produce 
"simplifications" (actually "complexifications") that you do not want. 
One possibility is to define a complexity function that penalises the 
presence of high powers, for example:


f[expr_] := With[{a = Cases[expr,
       Power[_, n_?NumericQ] -> Abs[n], Infinity]}, If[a == {},
                 0, Max[a]]] + LeafCount[expr]

I added LeafCount because we also want to keep this to minimum. With 
this complexity function we get the desired simplification:


Simplify[Sqrt[x^2 + x^4], x >= 0,
   ComplexityFunction -> f]

x*Sqrt[x^2 + 1]


and also


Simplify[Sqrt[x^(-2) + x^(-4)],
   x >= 0, ComplexityFunction -> f]


Sqrt[x^2 + 1]/x^2

Of course you need the assumption that x>0!


Andrzej Kozlowski
Chiba, Japan
http://www.akikoz.net/andrzej/index.html
http://www.mimuw.edu.pl/~akoz/


  • Prev by Date: Re: Pattern gremlins.
  • Next by Date: Re: Pattern gremlins.
  • Previous by thread: Re: Simplfying inside Sqrt
  • Next by thread: Plotting a super ellipse