# Properly simplifying a complicated expression with square roots

I'm having trouble simplifying (a family of) complicated rational expressions. For instance, I obtained the following $$expr=\frac{\sqrt{3} \left(\frac{\sqrt{\frac{\tau ^3 (\tau +2) (\lambda -\tau +1) (\lambda +\tau +2)}{\lambda (\lambda +3)}}}{(\tau +1) (2 \tau +1)}+\frac{2 \sqrt{\tau (\tau +2)} (\lambda -2 \tau (\tau +2))}{\sqrt{\lambda (\lambda +3)} (4 \tau (\tau +2)+3)}-\frac{1}{\sqrt{\frac{\lambda (\lambda +3) (\tau +1)^2 (2 \tau +3)^2}{\tau (\tau +2)^3 (\lambda -\tau ) (\lambda +\tau +3)}}}\right)}{\sqrt{(\lambda +1) (\lambda +2)}}$$ as a result of

FullSimplify[expr,  Assumptions -> {lambda> 0, tau > 0, tau <= lambda}]


Here's the same expression in InputForm:

 expr = (Sqrt[3]*(Sqrt[((1 + lambda - tau)*tau^3*(2 + tau)*(2 + lambda + tau))/(lambda*(3 + lambda))]/((1 + tau)*(1 + 2*tau)) -
1/Sqrt[(lambda*(3 + lambda)*(1 + tau)^2*(3 + 2*tau)^2)/((lambda - tau)*tau*(2 + tau)^3*(3 + lambda + tau))] +
(2*Sqrt[tau*(2 + tau)]*(lambda - 2*tau*(2 + tau)))/(Sqrt[lambda*(3 + lambda)]*(3 + 4*tau*(2 + tau)))))/Sqrt[(1 + lambda)*(2 + lambda)]


There are clear additional simplifications, such as factors of $\sqrt{(\tau+1)^2}$, commons factors of $\lambda (\lambda+3)$ and the last term, with the inverse fraction in the denominator, is annoying because when $\lambda=\tau$ it appears there is a $0$ in one of the denominators.

I followed the suggestion of this post

FullSimplify[ExpandAll@expr,  Assumptions -> {lambda> 0, tau > 0, tau<= lambda}]


but this returns $$\frac{\sqrt{3} \tau \sqrt{\frac{(\tau +2) (\tau +3)}{(\lambda +1) (\lambda +2)}} \left(2 \sqrt{\frac{\lambda ^3 (\lambda +3)}{\tau (\tau +3)}}+2 \sqrt{\frac{\lambda ^3 (\lambda +3) \tau }{\tau +3}}-4 \sqrt{\frac{\lambda (\lambda +3) \tau ^5}{\tau +3}}-12 \sqrt{\frac{\lambda (\lambda +3) \tau ^3}{\tau +3}}+2 \sqrt{\frac{\lambda (\lambda +3) \tau ^3 (\lambda -\tau +1) (\lambda +\tau +2)}{\tau +3}}-2 \sqrt{\frac{\lambda (\lambda +3) \tau ^3 (\lambda -\tau ) (\lambda +\tau +3)}{\tau +3}}-8 \sqrt{\frac{\lambda (\lambda +3) \tau }{\tau +3}}+3 \sqrt{\frac{\lambda (\lambda +3) \tau (\lambda -\tau +1) (\lambda +\tau +2)}{\tau +3}}-2 \sqrt{\frac{\lambda (\lambda +3) (\lambda -\tau ) (\lambda +\tau +3)}{\tau (\tau +3)}}-5 \sqrt{\frac{\lambda (\lambda +3) \tau (\lambda -\tau ) (\lambda +\tau +3)}{\tau +3}}\right)}{\lambda (\lambda +3) (\tau +1) (2 \tau +1) (2 \tau +3)}$$ which removes some of the irksome problems of apparently singular expressions in denominators (although the $\tau$ factor in front would cancel some denominator factors of $\sqrt{\tau}$ thus removing the singularity issue for $\tau=0$) but is not that much better as there are still lots of common factors, again like $\sqrt{\lambda(\lambda+3)}$ and $\sqrt{\tau+3}$.

This one expression turns out to be always $<0$ over the allowed range of $\tau$ so I thought of multiplying by $-1$, squaring and taking the square root but this doesn't seem productive (and is very time consuming) because the square roots don't go away "nicely" upon squaring.

This is one of a series of expression of similar structure (always a sum of $3$ terms) and complexity so I wonder if there is a better way to proceed, possibly starting from the last expression, to properly factor the common terms.

• @MarcoB Thanks for the edit but could you quickly point out I didn't do properly so I can do it right next time? – ZeroTheHero May 9 '18 at 22:50

Perhaps you can use PowerExpand, although it will need some help to arrive at your desired goal. Note that by default PowerExpand makes assumptions about symbols that may not be true, meaning that the power expanded form may not be equal to the original form. However, you can use the Assumptions option of PowerExpand, in which case you should expect that the power expanded form is a simplification of the original form. In this case, the default assumptions are probably ok:

PowerExpand[expr] //TeXForm


$\frac{\sqrt{3} \left(\frac{\sqrt{\tau +2} \tau ^{3/2} \sqrt{\lambda -\tau +1} \sqrt{\lambda +\tau +2}}{\sqrt{\lambda } \sqrt{\lambda +3} (\tau +1) (2 \tau +1)}-\frac{(\tau +2)^{3/2} \sqrt{\tau } \sqrt{\lambda -\tau } \sqrt{\lambda +\tau +3}}{\sqrt{\lambda } \sqrt{\lambda +3} (\tau +1) (2 \tau +3)}+\frac{2 \sqrt{\tau +2} \sqrt{\tau } (\lambda -2 \tau (\tau +2))}{\sqrt{\lambda } \sqrt{\lambda +3} (4 \tau (\tau +2)+3)}\right)}{\sqrt{\lambda +1} \sqrt{\lambda +2}}$

Here's the version where you give explicit assumptions:

PowerExpand[expr, Assumptions->0<tau<=lambda] //TeXForm


$\frac{\sqrt{3} \tau ^{3/2} \sqrt{\frac{(\tau +2) (\lambda -\tau +1) (\lambda +\tau +2)}{\lambda (\lambda +1) (\lambda +2) (\lambda +3)}}}{(\tau +1) (2 \tau +1)}-\frac{\sqrt{3} (\tau +2)^{3/2} \sqrt{\lambda -\tau } \sqrt{\frac{\tau (\lambda +\tau +3)}{\lambda (\lambda +1) (\lambda +2) (\lambda +3)}}}{(\tau +1) (2 \tau +3)}+\frac{2 \sqrt{3} \sqrt{\frac{\tau (\tau +2)}{\lambda (\lambda +1) (\lambda +2) (\lambda +3)}} (\lambda -2 \tau (\tau +2))}{4 \tau (\tau +2)+3}$

• As an update: a little more mileage was obtained by "manually" identifying the common terms and finally using PowerExpand[Sqrt[$\lambda (1+\lambda)(2+\lambda)(3+\lambda)$ expr /$\sqrt{3\tau(2+\tau)}$,Assumptions...] and this is good enough for the expressions I have to deal with. This gets rids of the troublesome singularities in the denominator. – ZeroTheHero May 10 '18 at 12:50