# Simplifying square roots of squared reals

I am using Mathematica to check some long, tedious calculations and I am stumped by some mysterious behavior. If I simplify a long expression that clearly has square real factors under a radical, for some reason Simplify and FullSimplify will not extract them even if I declare them as being real. Here is the behavior I expect, and I see it in this simple case:

In[1]:= FullSimplify[Sqrt[b^2], b \[Element] Reals]

Out[1]= Abs[b]


This is fine, but when I try something just slightly more complex it fails entirely:

In[2]:= FullSimplify[Sqrt[b^2 + b^4], b \[Element] Reals]

Out[2]= Sqrt[b^2 + b^4]


It seems clear that the result should be Abs[b]*Sqrt[1+b^2]. I have tried adding //PowerExpand as well as Assuming[b \[Element] Reals, FullSimplify[Sqrt[b^2 + b^4]]] and neither gives the expected result.

• Assuming[Element[b, Reals], Simplify /@ ((Sqrt[b^2 + b^4] // Factor) /. Sqrt[x_ y_] :> Sqrt[x] Sqrt[y])] Feb 25, 2020 at 0:18

FullSimplify[Sqrt[b^2 + b^4], {b} \[Element] Reals,
ComplexityFunction -> (SimplifySimplifyCount[#] +
Total@Cases[#, Power[_, p_?NumericQ] :> Abs[p], Infinity] &)]
(* Sqrt[1 + b^2] Abs[b]  *)


To further encourage low-power output, increase the coefficient of Total@...:

 ComplexityFunction -> (SimplifySimplifyCount[#] +
5 * Total@Cases[#, Power[_, p_?NumericQ] :> Abs[p], Infinity] &)]


Mathematica doesn't agree that the second result is simpler. It judges complexity (in part) by LeafCount. The second expression has a slightly higher value.

LeafCount[Sqrt[b^2 + b^4]]
(* 11 *)

LeafCount[Abs[b] Sqrt[1 + b^2]]
(* 12 *)


You might be able to use a custom ComplexityFunction to get round this, but I would find another route to achieve this simplification.

Sqrt[b^2 + b^4] // Factor // PowerExpand


gets you close.

• Using PowerExpand[#, {b^2}] & instead of just PowerExpand gets you closer. Feb 24, 2020 at 23:12