# Simplify radical expression (a + b - Sqrt[a^2 - b^2])/Sqrt[a + b]

I have the following expansions:

$$\frac{a+b-\sqrt{a^2-b^2}}{\sqrt{a+b}}$$ and $$a>b>0$$
Obviously we can simplify it further by hand $$\sqrt{a+b}-\sqrt{a-b}$$, but Mathematica doesn't know how to simplify it, I have tried several methods, but nothing worked.

FullSimplify[(a + b - Sqrt[a^2 - b^2])/Sqrt[a + b], a > b > 0,
ComplexityFunction -> #] & /@ {LeafCount, ByteCount, StringLength@*ToString}

• What's puzzling here is that the target expression has a lower LeafCount, ByteCount, and StringLength than the original expression. (26 vs. 19, 744 vs. 536, and 81 vs. 26 respectively.) You would think that this would induce Mathematica to return it in at least one of the cases. Oct 13, 2021 at 15:28

expr = (a + b - Sqrt[a^2 - b^2 // Factor])/Sqrt[a + b] // PowerExpand // Apart

(*Sqrt[a + b] - Sqrt[a - b]*)


We can cherry pick a custom ComplexityFunction that rewards positive exponents:

posPowerComplexity[expr_] := LeafCount[expr] - 5Count[expr, Power[_, _?Positive], ∞]

FullSimplify[(a + b - Sqrt[a^2 - b^2])/Sqrt[a + b], a > b > 0,
ComplexityFunction -> posPowerComplexity]

Sqrt[a + b] - Sqrt[a - b]

• Nice, but changing that magic number 5 breaks the solution, so it looks like it's a bit of a gamble finding what works and what doesn't. Oct 13, 2021 at 15:40
• Agreed $\,\,\,\,$ Oct 13, 2021 at 15:47
• how would a complexity function "same as before, but avoid roots in denominator" look like? on that note, how does one even access default complexity function? Oct 14, 2021 at 14:15
• The default complexity function can be seen here. It's essentially just LeafCount that also takes into account length of exact numeric quantities. A low level implementation is available through the undocumented symbol SimplifySimplifyCount. Oct 14, 2021 at 18:04

(a + b - Sqrt[a^2 - b^2])/Sqrt[a + b] //
Apart //
PowerExpand[#, Assumptions -> {a > b > 0}] & //
Simplify

(*   -Sqrt[a - b] + Sqrt[a + b]   *)


The problem consists in the following: PowerExpand[Sqrt[x*y]] works, but PowerExpand[Sqrt[a^2 - b^2]] doesn't. So

Expand[FullSimplify[PowerExpand[
FullSimplify[(a + b - Sqrt[a^2 - b^2])/Sqrt[a + b] /. {a -> x + y, b -> x - y},
Assumptions -> x + y > x - y > 0]]] /. {x -> (a + b)/2,  y -> (a - b)/2}]


-Sqrt[a - b] + Sqrt[a + b]

• So does Expand[FullSimplify[ PowerExpand[ FullSimplify[(a + b - Sqrt[a^2 - b^2])/Sqrt[a + b] /. {a -> x + y, b -> x - y}]]] /. {x -> (a + b)/2, y -> (a - b)/2}]. Oct 13, 2021 at 17:22

Try this:

expr = (a + b - Sqrt[a^2 - b^2])/Sqrt[a + b];

MapAt[ReplaceAll[#, a + b -> Sqrt[a + b]*Hold@Sqrt[a + b]] &, expr,
2] // Simplify[#, a > b > 0] & // ReleaseHold

(*   -Sqrt[a - b] + Sqrt[a + b]   *)
`

Have fun!