3
$\begingroup$

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...

$\endgroup$
2
$\begingroup$

There is no bug. The solution provided by Mathematica can easily be shown to satisfy the differential equation.

$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][[1]] // FullSimplify

(* {y -> Function[{x}, 
   x^((Sqrt[-a^2 + 
       b^2] (-((Sqrt[2] Sqrt[-2 a^2 + b^2])/Sqrt[a^2 - b^2]) - (Sqrt[2] b)/
        Sqrt[-a^2 + b^2]))/(2 Sqrt[2] b)) C[1] + 
    x^((Sqrt[-a^2 + 
       b^2] ((Sqrt[2] Sqrt[-2 a^2 + b^2])/Sqrt[a^2 - b^2] - (Sqrt[2] b)/
        Sqrt[-a^2 + b^2]))/(2 Sqrt[2] b)) C[2]]} *)

Verifying solution

eqn /. sol // Simplify

(* True *)

Using function with explicit argument

sol2 = DSolve[eqn, y[x], x][[1]] // FullSimplify

(* {y[x] -> x^(-((b + (Sqrt[-2 a^2 + b^2] Sqrt[-a^2 + b^2])/Sqrt[a^2 - b^2])/(
    2 b))) (C[1] + 
     x^((Sqrt[-2 a^2 + b^2] Sqrt[-a^2 + b^2])/(b Sqrt[a^2 - b^2])) C[2])} *)

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 *)
$\endgroup$
  • $\begingroup$ 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? $\endgroup$ – xiaohuamao Jan 4 at 1:20
  • 1
    $\begingroup$ Mathematica assumes variables are complex unless told otherwise or the context is implicitly real (e.g., probability distributions). $\endgroup$ – Bob Hanlon Jan 4 at 6:07
  • $\begingroup$ 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). $\endgroup$ – user64494 Jan 4 at 7:15
  • $\begingroup$ @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. $\endgroup$ – Bob Hanlon Jan 4 at 14:18
2
$\begingroup$

$\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.

$\endgroup$
1
$\begingroup$

This can be fixed as follows.

$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\} $$

$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\} $$

$\endgroup$

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.