# Oversimplify of products of square roots in DSolve solution

The following code solves a simple 2nd-order linear differential equation with all real parameters.

FullSimplify[
DSolve[(4 q^2 r - b^2 r^3 + 8 p q s + (4 p^2 s^2)/r - 4 r m^2)/(4 r)
f[y] - b^2 r^2 y (2 D[f[y], y] +
y D[f[y], {y, 2}]) == 0, f[y], y,
Assumptions -> Element[q | r | p | s | b | m, Reals]],
Assumptions -> Element[q | r | p | s | b | m, Reals]]


The result is as horrible as$$y^{\frac{1}{2} \left(-\frac{\sqrt{r^2 \left(b^2 r^2+4 m^2-4 q^2\right)-4 p^2 s^2-8 p q r s} \sqrt{\frac{r^4}{r^2 \left(b^2 r^2+4 m^2-4 q^2\right)-4 p^2 s^2-8 p q r s}-\frac{1}{b^2}}}{r^2}-1\right)} \left(c_2 y^{\frac{\sqrt{r^2 \left(b^2 r^2+4 m^2-4 q^2\right)-4 p^2 s^2-8 p q r s} \sqrt{\frac{r^4}{r^2 \left(b^2 r^2+4 m^2-4 q^2\right)-4 p^2 s^2-8 p q r s}-\frac{1}{b^2}}}{r^2}}+c_1\right).$$ However, without any further assumption, I found by hand that the solution is actually just $$c_2 y^{\frac{\sqrt{D }}{r^2 \left| b\right| }-\frac{1}{2}}+c_1 y^{-\frac{\sqrt{D }}{r^2 \left| b\right| }-\frac{1}{2}},$$ where $$D=(ps+qr)^2-r^2m^2$$.

I tried various assumptions but no available except directly using $$D$$ (DD in the code) to replace things from the very beginning

Assuming[Element[DD | r | b, Reals],
f[y] /. DSolve[(DD/r^2 - b^2 r^2/4) f[y] - b^2 r^2 y (2 D[f[y], y]
+ y D[f[y], {y, 2}]) == 0, f[y], y][] // FullSimplify] // Expand


The result is exactly what I found by hand. But this is no more than Monday morning quarterback. Note that mathematically there should be no difference between assuming Element[DD | r | b, Reals] and Element[q | r | p | s | b | m, Reals]. It looks as though MMA 'oversimplifies', albeit correctly, rendering it hard to recover without ad hoc assumptions what one would normally want...

So how can one obtain this in a somewhat elegant or at least general manner? I still hope some approach 'better' than an ad hoc assumption in @Bob Hanlon 's answer.

Clear["Global*"]

eqn = (4 q^2 r - b^2 r^3 + 8 p q s + (4 p^2 s^2)/r - 4 r m^2)/(4 r)
f[y] - b^2 r^2 y (2 D[f[y], y] + y D[f[y], {y, 2}]) == 0;

expr1 = Assuming[Element[q | r | p | s | b | m, Reals],
f[y] /. DSolve[eqn, f[y], y][] // FullSimplify] // Expand

(* y^(1/2 (-1 - (
Sqrt[r^2 (4 m^2 - 4 q^2 + b^2 r^2) - 8 p q r s - 4 p^2 s^2]
Sqrt[-(1/b^2) + r^4/(
r^2 (4 m^2 - 4 q^2 + b^2 r^2) - 8 p q r s - 4 p^2 s^2)])/r^2)) C +
y^((Sqrt[r^2 (4 m^2 - 4 q^2 + b^2 r^2) - 8 p q r s - 4 p^2 s^2]
Sqrt[-(1/b^2) + r^4/(
r^2 (4 m^2 - 4 q^2 + b^2 r^2) - 8 p q r s - 4 p^2 s^2)])/r^2 +
1/2 (-1 - (
Sqrt[r^2 (4 m^2 - 4 q^2 + b^2 r^2) - 8 p q r s - 4 p^2 s^2]
Sqrt[-(1/b^2) + r^4/(
r^2 (4 m^2 - 4 q^2 + b^2 r^2) - 8 p q r s - 4 p^2 s^2)])/r^2)) C *)


Assuming temporarily that the conditions are met such that Sqrt[a] Sqrt[b] == Sqrt[a*b]

expr2 = expr1 /. Sqrt[a_] Sqrt[b_] -> Sqrt[a*b] // Simplify // Expand

(* y^(-(1/2) - Sqrt[(-m^2 r^2 + (q r + p s)^2)/b^2]/r^2) C +
y^(-(1/2) + Sqrt[(-m^2 r^2 + (q r + p s)^2)/b^2]/r^2) C *)


Showing that the expr2 satisfies eqn more generally,

eqn /. {f -> Function[{y}, Evaluate@expr2]} // Simplify

(* True *)

• Thanks. I know what you mean. But it actually doesn't falsify my simplification. As I mentioned in the question, you can easily see this by using $\Delta$ from the very beginning. Assuming[Element[DD | r | b, Reals], f[y] /. DSolve[(DD/r^2 - b^2 r^2/4) f[y] - b^2 r^2 y (2 D[f[y], y] + y D[f[y], {y, 2}]) == 0, f[y], y][] // FullSimplify] // Expand` They are mathematically the same thing. – xiaohuamao Jan 5 '19 at 7:57
• It's easy to see for the invalid case you claimed, the two solutions simply interchange and the whole expression stays the same. So your answer doesn't really answer it. – xiaohuamao Jan 5 '19 at 17:22
• Thank you for the edit. It looks as though MMA 'oversimplifies' a little, albeit correctly, rendering it not easy to recover what one would normally want without ad hoc assumptions... – xiaohuamao Jan 6 '19 at 6:00