0
$\begingroup$

I have acquired the following root from a minimization problem:

Root[1 + 2/(1 - 2 p)^4 - 3/(1 - 2 p)^2 - 4 p + 4 p^2 - 
   16 Sqrt[-(((-1 + p)^3 p^3)/(-1 + 2 p)^8)] + (12 p - 
      12 p^2) #1 + (-12 p + 12 p^2) #1^2 + (-1 + 4 p - 4 p^2) #1^3 &,
  2]

For numerics this is an unnecessary nasty form and often generates small imaginary parts on the range where the value is actually real.

I'm particularly interested of the value when $0 \leq p \leq 1$. In this case I can use ToRadicals to ease FullSimplifying the Root:

FullSimplify[ToRadicals@%, 0 <= p <= 1]

$$\frac{2 \left(2 (p-1) p+\sqrt{-(p-1) p}\right)}{(1-2 p)^2}$$

Now, this is much more understandable and numerically neat. This feels to me a bit of a hack, though; I would be interested of hearing of a more generic method for this kind of root simplification with assumptions; clearly I can't expect ToRadicals to work for all polynomials. Also, I found out that FullSimplify with assumptions does nothing to the original Root object...

$\endgroup$
  • $\begingroup$ Did you include the constraint 0<=p<=1 in the minimization process? $\endgroup$ – Bob Hanlon Jan 14 at 0:14
  • $\begingroup$ @BobHanlon Yep, doesn't make a difference. $\endgroup$ – kirma Jan 14 at 18:50
1
$\begingroup$

It looks like you are basically looking for the region in p where the expression is real-valued. You can find this using Reduce. With exp equal to your expression,

reg = Reduce[exp>0]
0 < p < 1/2 || 1/2 < p < 1

FullSimplify[ToRadicals[exp], reg]
(2 (2 (-1 + p) p + Sqrt[-(-1 + p) p]))/(1 - 2 p)^2

returns your desired form.

$\endgroup$
  • $\begingroup$ I'm wishing to avoid using ToRadicals - although you can certainly ease finding the region with Reduce, or, say, FunctionDomain. $\endgroup$ – kirma Jan 13 at 8:27
1
$\begingroup$

Mathematica often considers Root objects as simpler forms since they can have a much lower LeafCount. For example,

sol = Solve[x^3 - 7 x + 2 == 0, x]

(* {{x -> (-9 + 2 I Sqrt[237])^(1/3)/3^(2/3) + 7/(3 (-9 + 2 I Sqrt[237]))^(
    1/3)}, {x -> -(((1 + I Sqrt[3]) (-9 + 2 I Sqrt[237])^(1/3))/(
     2 3^(2/3))) - (7 (1 - I Sqrt[3]))/(
    2 (3 (-9 + 2 I Sqrt[237]))^(
     1/3))}, {x -> -(((1 - I Sqrt[3]) (-9 + 2 I Sqrt[237])^(1/3))/(
     2 3^(2/3))) - (7 (1 + I Sqrt[3]))/(2 (3 (-9 + 2 I Sqrt[237]))^(1/3))}} *)

sol2 = sol // FullSimplify

(* {{x -> Root[2 - 7 #1 + #1^3 &, 3]}, {x -> Root[2 - 7 #1 + #1^3 &, 2]}, {x -> 
   Root[2 - 7 #1 + #1^3 &, 1]}} *)

LeafCount /@ {sol, sol2}

(* {187, 52} *)

To return to the radical form you would need to either use ToRadicals or a custom ComplexityFunction

In your case, until the constraint on p is known, the Root object is simpler

expr = Root[
   1 + 2/(1 - 2 p)^4 - 3/(1 - 2 p)^2 - 4 p + 4 p^2 - 
     16 Sqrt[-(((-1 + p)^3 p^3)/(-1 + 2 p)^8)] + (12 p - 
        12 p^2) #1 + (-12 p + 12 p^2) #1^2 + (-1 + 4 p - 4 p^2) #1^3 &, 2];

expr2 = expr // ToRadicals // FullSimplify

(* (p + I Sqrt[3]
     p + (1 - I Sqrt[3]) ((1 - 2 p)^4 Sqrt[-(((-1 + p)^3 p^3)/(1 - 2 p)^8)])^(
    2/3) - 4 p (Sqrt[-(((-1 + p)^3 p^3)/(-1 + 2 p)^8)] (-1 + 2 p)^4)^(1/3) + 
   p^2 (-1 - I Sqrt[3] + 
      4 (Sqrt[-(((-1 + p)^3 p^3)/(-1 + 2 p)^8)] (-1 + 2 p)^4)^(1/3)))/((1 - 
     2 p)^2 ((1 - 2 p)^4 Sqrt[-(((-1 + p)^3 p^3)/(1 - 2 p)^8)])^(1/3)) *)

expr3 = expr // ToRadicals // FullSimplify[#, 0 <= p <= 1] &

(* (2 (2 (-1 + p) p + Sqrt[-(-1 + p) p]))/(1 - 2 p)^2 *)

LeafCount /@ {expr, expr2, expr3}

(* {95, 184, 26} *)
$\endgroup$
  • $\begingroup$ The idea of changing ComplexityFunction is a good idea, but curiously enough even plain LeafCount makes simplification of the Root object take effectively forever, thus making this approach impractical when trying to avoid ToRadicals. I think this is pretty curious... $\endgroup$ – kirma Jan 14 at 19:10
1
$\begingroup$

Unlike radical expressions, Root objects with exact coefficients resist the phenomenon of parasitic imaginary parts. Thus,

 Root[1 + 2/(1 - 2 p)^4 - 3/(1 - 2 p)^2 - 4 p + 4 p^2 - 
 16 Sqrt[-(((-1 + p)^3 p^3)/(-1 + 2 p)^8)] + (12 p - 
    12 p^2) #1 + (-12 p + 12 p^2) #1^2 + (-1 + 4 p - 
    4 p^2) #1^3 &, 2]] /. p -> Rationalize[pp, 0]

is purely real for 0<=pp<=1.

$\endgroup$

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.