9

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.

David G. Stork
  • 41,180
  • 3
  • 34
  • 96

4 Answers4

11

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.

mikado
  • 16,741
  • 2
  • 20
  • 54
1

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!

Alexei Boulbitch
  • 39,397
  • 2
  • 47
  • 96
1

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]) &;
Michael E2
  • 235,386
  • 17
  • 334
  • 747
0

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.

Akku14
  • 17,287
  • 14
  • 32
  • 2
    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 04 '19 at 13:55