8
$\begingroup$

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.

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

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.

$\endgroup$
3
  • 1
    $\begingroup$ You and Bob Hanlon have illuminated me $\endgroup$ – Gianfranco Zosi Dec 4 '19 at 7:25
  • $\begingroup$ 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 $\endgroup$ – Akku14 Dec 4 '19 at 8:27
  • $\begingroup$ This works really nice. Thank you $\endgroup$ – Saesun Kim Jan 28 '20 at 20:19
1
$\begingroup$

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!

$\endgroup$
1
$\begingroup$

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]) &;
$\endgroup$
0
$\begingroup$

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.

$\endgroup$
1
  • 1
    $\begingroup$ 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. $\endgroup$ – Michael E2 Dec 4 '19 at 13:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.