Memo for the moderator.
Sorry, I am new to "Ask a question". Is my writing correct ? Shall I receive a reply directly to my e-mail address or somewhere in the StackExchange?

My question: I want to simplify the following expression, when $$-1 < x < 1$$ and $$-1 < y < 1$$,

sol = Sqrt[1/(x + Sqrt[x^2 + y^2])].


By hand I obtain

 sol$rat = Sqrt[(-x + Sqrt[x^2 + y^2])/y^2]  but, as I have not been able to find a built-in command, I have tried naively, without success after several tests  rational$sol =
Sqrt[1/((x + Sqrt[x^2 + y^2]) (-x + Sqrt[x^2 + y^2]))*(-x + Sqrt[
x^2 + y^2])] // FullSimplify


When I search (e.g., stack exchange ...) "Simplifying Radicals in Numerator and Denominator - Mathematica," I see no satisfying solution.

• sol /. 1/(z1_ + Sqrt[z2_]) :> (z1 - Sqrt[z2])/(z1^2 - z2) – Bob Hanlon Dec 3 '19 at 23:39

You can guide the simplification by providing a ComplexityFunction. It seems that your aim is to make the denominator as simple as possible. With that in mind, I tried the following

Assuming[-1 < x < 1 && -1 < y < 1,
FullSimplify[sol,
ComplexityFunction -> (LeafCount[Denominator[#]] &)]] // Simplify

(* Sqrt[(-x + Sqrt[x^2 + y^2])/y^2] *)


The FullSimplify rewrites the denominator, the Simplify tidies the expression a little.

• You and Bob Hanlon have illuminated me – Gianfranco Zosi Dec 4 '19 at 7:25
• Unfortunately this result is not exact. sol has no singularity for positive x and y->0, but this result has a (but removable) singularity there. Look at my answer – Akku14 Dec 4 '19 at 8:27
• This works really nice. Thank you – Saesun Kim Jan 28 '20 at 20:19

Try also this:

Sqrt[Numerator[sol[[1]]]*(x - Sqrt[x^2 + y^2])/
Expand[Denominator[sol[[1]]]*(x - Sqrt[x^2 + y^2])]]

(*  Sqrt[-((x - Sqrt[x^2 + y^2])/y^2)]   *)


Have fun!

Here's a high-school algebra approach:

$rat = # /. Power[a_ + s_.*Sqrt[b_], -1] :> Power[(a^2 - s^2 b)/(a - s*Sqrt[b]), -1] &; sol //$rat
(*  Sqrt[-((x - Sqrt[x^2 + y^2])/y^2)]  *)


Other variants: The Power[.., -1] pattern above limits the applicability to a simple factor in the denominator (anywhere in the expression, by the way!).

$rat = # /. (* any factor in denominator *) Power[a_ + s_. * Sqrt[b_], p_?Negative] :> Power[(a^2 - s^2 b)/(a - s*Sqrt[b]), p] &;$rat = # /.   (* any sum involving Sqrt[] anywhere in the expression *)
a_ + s_. * Sqrt[b_] :>
(a^2 - s^2 b)/(a - s * Sqrt[b]) &;


Unfortunately the results given so far are not exact. sol has no singularity for positive x and y -> 0, but the other results have a (but removable) singularity there.

sol1[x_, y_] = Sqrt[1/(x + Sqrt[x^2 + y^2])];

sol2[x_, y_] = Sqrt[(-x + Sqrt[x^2 + y^2])/y^2];

{s1 = sol1[1/3, y], s1 /. y -> 0}

(*   {Sqrt[1/(1/3 + Sqrt[1/9 + y^2])], Sqrt[3/2]}   *}

{s2 = sol2[1/3, y], s2 /. y -> 0, Limit[s2, y -> 0]}

(* {Sqrt[(-(1/3) + Sqrt[1/9 + y^2])/y^2], Indeterminate, Sqrt[3/2]} *}


The simplification Mathematica did with 'ComplexityFunction' is not exact.

• Instead of "not exact," the docs describe the results as "generically equivalent." In general, Mathematica does algebra with generic transformations. Consider x/x, and the docs for Solve, Integrate, and FullSimplify explicitly warn this. From the point of view of algebra, this is fine and accepted in mathematics; from the point of view of functions and their domains, your criticism is valid. Note that the OP's desired solution sol\$rat is also only generically equivalent. – Michael E2 Dec 4 '19 at 13:55