# DSolve returns incorrect solution by automatically assuming positive parameters?

The following code solves a simple 2nd-order linear ODE with real parameters $$a,b$$.

FullSimplify@
DSolve[(a^2 - b^2) y[x] -
2 b^2 x (2 D[y[x], x] + x D[y[x], {x, 2}]) == 0, y[x], x]


The result is $$x^{-\frac{\frac{\sqrt{b^2-2 a^2} \sqrt{b^2-a^2}}{\sqrt{a^2-b^2}}+b}{2 b}} \left(c_2 x^{\frac{\sqrt{b^2-2 a^2} \sqrt{b^2-a^2}}{b \sqrt{a^2-b^2}}}+c_1\right).$$

However, this has an obvious flaw. $$b$$ itself should not appear since only $$b^2$$ enters the original equation. The true solution is just b replaced by Abs[b]. One can remove FullSimplify to check. It looks as if DSolve sneakily assumes $$b>0$$.

Is it a bug? I don't think MMA usually assumes positive parameters.
A minor issue is how to really simplify those apparently cancelling square roots...

$Version (* "11.3.0 for Mac OS X x86 (64-bit) (March 7, 2018)" *)  Using pure function (easier to verify solution) eqn = (a^2 - b^2) y[x] - 2 b^2 x (2 D[y[x], x] + x D[y[x], {x, 2}]) == 0; sol = DSolve[eqn, y, x][] // FullSimplify (* {y -> Function[{x}, x^((Sqrt[-a^2 + b^2] (-((Sqrt Sqrt[-2 a^2 + b^2])/Sqrt[a^2 - b^2]) - (Sqrt b)/ Sqrt[-a^2 + b^2]))/(2 Sqrt b)) C + x^((Sqrt[-a^2 + b^2] ((Sqrt Sqrt[-2 a^2 + b^2])/Sqrt[a^2 - b^2] - (Sqrt b)/ Sqrt[-a^2 + b^2]))/(2 Sqrt b)) C]} *)  Verifying solution eqn /. sol // Simplify (* True *)  Using function with explicit argument sol2 = DSolve[eqn, y[x], x][] // FullSimplify (* {y[x] -> x^(-((b + (Sqrt[-2 a^2 + b^2] Sqrt[-a^2 + b^2])/Sqrt[a^2 - b^2])/( 2 b))) (C + x^((Sqrt[-2 a^2 + b^2] Sqrt[-a^2 + b^2])/(b Sqrt[a^2 - b^2])) C)} *)  Verifying solution, eqn /. (NestList[D[#, x] &, sol2, 2] // Flatten // Simplify) // FullSimplify (* True *)  Verifying that solutions are equivalent (y[x] /. sol) == (y[x] /. sol2) // Simplify (* True *)  There are no assumptions about b. a and b can even be complex (eqn /. {a -> c + I*d, b -> e + I*f}) /. (sol /. {a -> c + I*d, b -> e + I*f}) // Simplify (* True *)  • Thanks for the clarification. You’re right. I suddenly realized it’s a silly question regarding somewhat a coincidence. BTW, do you think MMA assumes real or complex parameters here? – xiaohuamao Jan 4 '19 at 1:20 • Mathematica assumes variables are complex unless told otherwise or the context is implicitly real (e.g., probability distributions). – Bob Hanlon Jan 4 '19 at 6:07 • It would be useful to verify the solution for concrete values of the parameters (in particular, taking$b$negative) because there is a chance that the above simplifications are formal (i.e. the simplifications don't take into account branches of the roots). – user64494 Jan 4 '19 at 7:15 • @user64494 - If you find a counter example, recommend that you post a question concerning that example. Note that any such example must allow for the arbitrary constants being arbitrary complex values. – Bob Hanlon Jan 4 '19 at 14:18 $$\left(a^2-b^2\right) y(x)-2 b^2 x \left(x y''(x)+2 y'(x)\right)=0$$ is an Euler-type DE so substituting $$y = x^r$$ into the DE we get $$x^r \left(a^2-b^2 (2 r (r+1)+1)\right)=0$$ and solving for $$r$$ we get $$r = \frac{\pm\sqrt{2 a^2 b^2-b^4}-b^2}{2 b^2}$$ or $$r = \{-\frac 12\left(\sqrt{2(\frac ab)^2-1}+1\right),\frac 12\left(\sqrt{2(\frac ab)^2-1}-1\right)\}$$ so the general solution is $$y=C_1 x^{-\frac 12\left(\sqrt{2(\frac ab)^2-1}+1\right)}+C_2 x^{\frac 12\left(\sqrt{2(\frac ab)^2-1}-1\right)}$$. I hope this helps. This can be fixed as follows. $Assumptions =  a^2 > b^2;

$$\left\{\left\{y(x)\to c_1 x^{\frac{1}{2} \left(-\sqrt{\frac{2 a^2}{b^2}-1}-1\right)}+c_2 x^{\frac{1}{2} \left(-\sqrt{\frac{2 a^2}{b^2}-1}-1\right)+\sqrt{\frac{2 a^2}{b^2}-1}}\right\}\right\}$$
\$Assumptions = a^2 < b^2; Expand[FullSimplify[DSolve[(a^2 - b^2) y[x] - 2 b^2 x (2 D[y[x], x] + x D[y[x], {x, 2}]) == 0, y[x], x]]]

$$\left\{\left\{y(x)\to c_1 x^{\frac{1}{2} \left(-\sqrt{\frac{2 a^2}{b^2}-1}-1\right)}+c_2 x^{\frac{1}{2} \left(-\sqrt{\frac{2 a^2}{b^2}-1}-1\right)+\sqrt{\frac{2 a^2}{b^2}-1}}\right\}\right\}$$