4
$\begingroup$

I have a relatively simple expression here that is not simplifying:

$$ \frac{2 s_0 \left(\sqrt{\gamma ^5 s_0}+\sqrt{\gamma ^9 s_0}\right)+\sqrt{\gamma ^3 s_0}+2 \sqrt{\gamma ^7 s_0}+\sqrt{\gamma ^{11} s_0}+\sqrt{\gamma ^7 s_0^5}}{\gamma \left(\gamma ^2+\gamma s_0+1\right){}^2} $$

$Assumptions = {(s0 | γ) ∈ Reals, γ > 0, s0 > 0}; (Sqrt[s0 γ^3] + 2 Sqrt[s0 γ^7] + Sqrt[s0^5 γ^7] + Sqrt[s0 γ^11] + 2 s0 (Sqrt[s0 γ^5] + Sqrt[s0 γ^9]))/(γ (1 + s0 γ + γ^2)^2) // Simplify (Sqrt[s0 γ^3] + 2 Sqrt[s0 γ^7] + Sqrt[s0^5 γ^7] + Sqrt[s0 γ^11] + 2 s0 (Sqrt[s0 γ^5] + Sqrt[s0 γ^9]))/(γ (1 + s0 γ + γ^2)^2) == Sqrt[s0 γ] // Simplify 

The output is:

(Sqrt[s0 γ^3] + 2 Sqrt[s0 γ^7] + Sqrt[s0^5 γ^7] + Sqrt[s0 γ^11] + 2 s0 (Sqrt[s0 γ^5] + Sqrt[s0 γ^9]))/(γ (1 + s0 γ + γ^2)^2) True 

Why is Mathematica not simplifying to this much simpler form $\sqrt{s_0 \gamma}$? I think my assumptions should be enough. I can do the simplification by hand

$\endgroup$
3
  • 1
    $\begingroup$ Assuming[{γ>0,s0>0},(Sqrt[s0 γ^3]+2 Sqrt[s0 γ^7]+Sqrt[s0^5 γ^7]+Sqrt[s0 γ^11]+2 s0 (Sqrt[s0 γ^5]+Sqrt[s0 γ^9]))/(γ (1+s0 γ+γ^2)^2)//Refine//Simplify] $\endgroup$ Commented Jul 3, 2020 at 10:20
  • $\begingroup$ @chyanog why do I need refine as well as simplify? $\endgroup$ Commented Jul 3, 2020 at 10:24
  • 2
    $\begingroup$ From the documentation of Sqrt: Sqrt[z^2] is not automatically converted to z. (And then they recommend the usage of PowerExpand for positive, real z.) $\endgroup$ Commented Jul 3, 2020 at 11:23

2 Answers 2

5
$\begingroup$
 expr = (Sqrt[s γ^3] + 2 Sqrt[s γ^7] + Sqrt[s^5 γ^7] + Sqrt[s γ^11] + 2 s (Sqrt[s γ^5] + Sqrt[s γ^9]))/(γ (1 + s γ + γ^2)^2); Simplify[PowerExpand[expr]] 

Mathematica graphics

$\endgroup$
3
  • $\begingroup$ Thanks, I'm not sure why this is needed though $\endgroup$ Commented Jul 3, 2020 at 10:28
  • $\begingroup$ @JoeBentley Mathematica needs PowerExpand to open up the radicals. I guess this is by design. $\endgroup$ Commented Jul 3, 2020 at 10:29
  • $\begingroup$ @Nasser: Presumably because you don't want Mathematica doing things like $\sqrt{(-1)(-2)} = \sqrt{-1} \sqrt{-2}$ by default. $\endgroup$ Commented Jul 3, 2020 at 19:25
4
$\begingroup$

More by way of explanation of the "indifference" that causes Simplify to not budge. In order to factor the expression so that it can be reduced, all the square-roots have to be factored and initially the complexity (computed by Simplify`SimplifyCount, which is equivalent to LeafCount on these examples) remains the same:

Simplify`SimplifyCount[Sqrt[s0^5 γ^7]] Simplify`SimplifyCount[s0^(5/2) γ^(7/2)] 
(* 11 11 *) 

The actual algorithm used by Simplify is unknown (to me), but it makes sense to reject a transformation that results in an expression with the same complexity as measured by the ComplexityFunction (to avoid getting stuck in an infinite cycle of equivalent-complexity expressions).

While there is a simpler solution (see @Nasser's), another approach is to tweak ComplexityFunction to make the desired steps seem "simpler":

cf = LeafCount[#] + 2 Count[#, Power[_Times, _], {0, ∞}] &; Simplify[(Sqrt[s0 γ^3] + 2 Sqrt[s0 γ^7] + Sqrt[s0^5 γ^7] + Sqrt[s0 γ^11] + 2 s0 (Sqrt[s0 γ^5] + Sqrt[s0 γ^9]))/(γ (1 + s0 γ + γ^2)^2), γ > 0 && s0 > 0, ComplexityFunction -> cf] (* Sqrt[s0 γ] *) 

Raise the coefficient of Count[] in cf to 5 and the result will be Sqrt[s0] Sqrt[γ].

$\endgroup$

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.